Home
← All questions

Multiselect dropdown with search | Frontend Machine Coding

HardPremiumMachine Coding

Asked at Meta · Google · Uber

Frontend Machine Coding interview practice: Build a combobox-style multiselect with filtering, chips, and keyboard nav.

Problem

Build a multiselect dropdown for tagging (e.g. assign labels to an issue).

Requirements

  • Click input to open list; type to filter options.
  • Toggle selection with click or Space; show selected as removable chips.
  • Close on Escape or outside click.
  • Keyboard: ArrowDown/Up moves highlight, Enter toggles, Backspace removes last chip.
  • Announce count to screen readers.

Hints / Approach

  • State: open, query, highlightIndex, selected: Set<string>.
  • Filter: options.filter(o => o.label.includes(query)).
  • Outside click via useEffect + mousedown on document.
Premium question

Unlock the in-browser editor, test cases, and model solution with Mentoxis Premium.

Unlock with Premium