Skip to the page

Frontend system design · Design

Autocomplete / typeahead (system-level)

The interviewer asks

Design a reusable autocomplete component that product teams across the company will use for search, user pickers and address lookup.

Then

Follow-ups the interviewer asks next

  1. Popup inside an overflow:hidden dialog: which layer closes on Escape?
  2. A typing burst: when do requests fire (debounce vs throttle, min length, cancellation)?
  3. What a cached shorter query can and can't tell you.
  4. "Load more" on scroll while the query changes mid-scroll; then testing, SSR, and the phone on-screen keyboard.

The answer

What a strong answer covers

  • API: controlled/uncontrolled value, an async source(query, {signal}), renderItem, onSelect, minChars, debounceMs, cache strategy.
  • Architecture: input + popup (portal + layer manager) + list (virtualised) + a cache (LRU by normalised query; prefix reuse only for client-filterable sources).
  • Race handling: AbortController plus a latest-request guard. Offset pages shift when ranking changes, so match responses to inputs.
  • ARIA combobox, aria-live result counts, IME composition handling, mobile viewport and keyboard.

The red pen

Common traps

Avoid:a fetch per keystroke; ignoring IME/composition events; mouse-only.

Practise this out loud

Say your answer out loud to an AI interviewer that follows up, and get a score for it.

Practise by voice

Practise questions like this out loud

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview