Frontend School

Simple Project Selector Combobox

Machine Coding
easy

Simple Project Selector Combobox

Easy
React
TypeScript
UI
Combobox
Filtering

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.

  1. Render the Combobox: Display an input field and a dropdown list.
  2. 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.
  3. Select a Project: Allow users to select a project from the filtered list.
  4. Display Selection: Once a project is selected, its name should be clearly displayed (e.g., in the input field or below it).
  5. 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.

Constraints

Constraints & assumptions

  • You must use React and TypeScript.
  • The provided mock projects data should be used.
  • Focus on core combobox functionality; do not integrate with external APIs.
  • No external UI component libraries (e.g., Material UI, Ant Design) are allowed. Build using native HTML elements and React state.
  • Styling can be minimal, focusing on functionality and basic readability.
  • The component should handle a single selection only.

Out of scope

  • Advanced accessibility (e.g., ARIA attributes beyond basic structure).
  • Debouncing the search input.
  • Loading indicators for asynchronous data.
  • Multi-select functionality.
  • Custom rendering of list items.

What interviewers evaluate

  • Component Design & State Management: How well the component is structured, and how effectively React state and props are managed for filtering, selection, and UI visibility.
  • Core Logic Implementation: Accuracy and efficiency of the filtering algorithm and selection handling.
  • Interactive Experience: Responsiveness to user input (typing, clicking, keyboard navigation) and correct UI updates.
  • Code Quality: Readability, maintainability, and appropriate use of TypeScript for type safety.

Loading editor...