Airbnb Destination Autocomplete Search
At Airbnb, providing an intuitive and efficient search experience is paramount to helping guests find their perfect stay. A key component of this is the destination search bar, which guides users to valid and popular locations. This problem focuses on building an autocomplete search functionality for destinations, enhancing usability by suggesting options as the user types and reducing friction in the booking process. Your solution will directly impact how easily guests discover their next adventure on Airbnb.
Your task is to build a React component that provides an autocomplete search experience for Airbnb destinations. You will be provided with a mock API function (mockFetchSuggestions) that simulates fetching destination data.
mockFetchSuggestions API to retrieve relevant destination suggestions. Implement debouncing to limit the frequency of API calls (e.g., 300ms).onSelectDestination callback should be invoked with the selected value.Up and Down arrow keys. Pressing Enter on a highlighted suggestion should select it, populate the input, and close the dropdown.aria-label, aria-autocomplete, aria-controls, role, aria-selected) are used where appropriate for the input and suggestion list.mockFetchSuggestions are debounced, meaning rapid typing does not trigger an API call for every keystroke.onSelectDestination callback.Down arrow key moves the highlight through suggestions; Up moves it backward.Enter on a highlighted suggestion selects it and performs the same actions as a click.Constraints
mockFetchSuggestions function simulates an asynchronous API call; you do not need to implement the backend or modify this function.mockFetchSuggestions API returns pre-filtered and relevant results based on the query. Your task is to integrate it, not to implement the filtering logic itself.mockFetchSuggestions function (currently 7).Loading editor...