Overview
In Atlassian products like Jira or Confluence, users frequently need to select a project from a potentially large list. A well-designed combobox component significantly enhances user experience by allowing quick searching and selection. This problem focuses on building a foundational combobox for project selection.
What you need to do / Task
Your task is to implement a Combobox component that allows users to search for and select a single project from a predefined list.
- Render the Combobox: Display an input field and a dropdown list.
- Filter Projects: As the user types into the input field, filter the list of available projects displayed in the dropdown. The filtering should be case-insensitive and match against the project's
name.
- Select a Project: Allow users to select a project from the filtered list.
- Display Selection: Once a project is selected, its name should be clearly displayed (e.g., in the input field or below it).
- Basic Keyboard Navigation: Implement basic keyboard navigation:
ArrowUp and ArrowDown keys should navigate through the visible (filtered) list items.
Enter key should select the currently highlighted item.
Escape key should close the dropdown without selecting.
UI/UX expectations
- The input field should be the primary interaction point for typing and filtering.
- The dropdown list should appear when the input is focused or typed into, and disappear when an item is selected, focus is lost, or
Escape is pressed.
- Filtered items should be clearly visible in the dropdown.
- The currently highlighted item (for keyboard navigation) should have a distinct visual style.
- After selection, the input field should reflect the selected project's name, or the selected project should be displayed prominently elsewhere. For this problem, let's keep it simple and update the input field with the selected project's name.
Acceptance criteria
- The combobox renders with an input field and a hidden dropdown.
- Typing in the input field filters the mock project list (case-insensitive match on
name).
- The dropdown list updates dynamically to show only filtered projects.
- Clicking on a project in the dropdown selects it, closes the dropdown, and updates the input value.
- Pressing
ArrowUp/ArrowDown highlights items in the dropdown.
- Pressing
Enter selects the highlighted item and closes the dropdown.
- Pressing
Escape closes the dropdown without selection.
- If no search term is entered, all projects are shown in the dropdown when it's open.