KatInterview

Building a Scalable Combobox Component

System DesignModel answer
MediumModel answerSystem Designfrontendcomponent-designaccessibility

Last updated

Architect a flexible, accessible dropdown component supporting various selection modes, data sources, and rendering up to 10,000 items efficiently.

Context

You need to create a shared combobox component for a large web application. The component will be used across many product surfaces with varying requirements: simple option pickers with a handful of static choices, searchable lists with remote data, and multi-select interfaces with thousands of items.

Your task is to design the architecture for this reusable component.

Requirements

Core Functionality

  • Selection patterns: Single-select and multi-select modes
  • Data handling: Both static arrays and async data with search filtering, debouncing, and pagination
  • Customization: Allow custom trigger buttons, item renderers, and empty/loading states
  • Control patterns: Support controlled (external state) and uncontrolled (internal state) usage

Quality Attributes

  • Accessibility: Implement W3C WAI-ARIA patterns correctly with full keyboard navigation (arrow keys, Enter, Escape, Home, End, and typeahead) plus screen reader compatibility
  • Performance: Maintain 60 FPS when rendering and scrolling through lists with 10,000+ items
  • Maintainability: Minimize unnecessary re-renders and keep the implementation modular

Deliverables

Design and explain:

  1. Public API: Propose the component interface—compound components, configuration props, or both. Justify your choice and show example usage in TypeScript or similar.

  2. State Architecture: Describe the internal state machine, including open/closed status, keyboard focus tracking, and selected values. Cover how you handle outside clicks, trigger interactions, and keyboard events.

  3. Accessibility Implementation: Specify the DOM structure, ARIA roles and attributes needed, and how keyboard navigation works.

  4. Performance Strategy: Explain your approach to efficiently rendering large lists and handling viewport positioning.

Hints

Hint 1

Consider whether compound components or configuration props offer better extensibility for diverse use cases

Hint 2

Think about why virtualizing the list matters when rendering thousands of items—what's the actual DOM cost?

Hint 3

ARIA's aria-activedescendant pattern keeps focus on the input while visually highlighting options