Frontendx
README.md
SOLUTION.md
main.tsxentry
App.tsx
App.css
index.html
vite.config.ts
Installed
react@^19.2.0
react-dom@^19.2.0

Search with Autocomplete - React

mediumreactautocompletesearchdebouncekeyboard-navdropdownuserefsde2googleuxGoogleMicrosoftUberUI Component

Prompt

Build a search input that shows a live dropdown of autocomplete suggestions. Suggestions are either fetched from an API or filtered from a static list on each debounced keystroke. Support full keyboard navigation (↑↓ arrows to move highlight, Enter to select, Escape to close). Close dropdown on outside click.

Debounce input 300ms. Store suggestions and focusedIndex in state. On ArrowDown increment focusedIndex (cap at length-1). On ArrowUp decrement (floor at 0). On Enter select suggestions[focusedIndex]. Use useRef + mousedown listener for outside-click detection.
Test Results

Search with Autocomplete - React

Build a search input that shows a live dropdown of autocomplete suggestions. Suggestions are either fetched from an API or filtered from a static list on each debounced keystroke. Support full keyboard navigation (↑↓ arrows to move highlight, Enter to select, Escape to close). Close dropdown on outside click.