Frontend School

Dynamic Multi-Select Dropdown with Search and Tagging

Machine Coding
hard

Dynamic Multi-Select Dropdown with Search and Tagging

Hard
React
TypeScript
Frontend
UI/UX
Component Design
Accessibility

Overview

In Postman, users frequently interact with large lists of entities such as collections, environments, or team members. Efficiently selecting multiple items from such lists is crucial for workflows like sharing, bulk operations, or filtering. This problem challenges you to build a robust and user-friendly multi-select dropdown component, mimicking the experience of selecting multiple tags or recipients, which is a fundamental UI pattern across our platform.

What you need to do / Task

Your goal is to develop a highly interactive and reusable MultiSelectDropdown React component. Specifically, you need to:

  1. Develop a MultiSelectDropdown React component that is generic and reusable.
  2. Accepts an array of options, where each option is an object with at least id (unique identifier) and name (display text) properties.
  3. Allows users to select multiple options. Selected options should be visually represented as "chips" or "tags" within the dropdown's input area.
  4. Implement a search/filter functionality within the dropdown. As the user types, the list of available options should dynamically update to show only matching items.
  5. Support individual deselection of items by clicking a 'remove' icon on their respective chips.
  6. Include a "Select All" / "Deselect All" option at the top of the dropdown list, which dynamically changes based on the current selection state (considering only filtered options).
  7. Manage dropdown open/close state based on user interaction (click outside, escape key, etc.).

UI/UX expectations

  • Input Area: Displays selected items as dismissible chips. A text input for search should be present within the input area.
  • Dropdown List: Appears below the input when active. It should be scrollable if options exceed visible height.
  • Options: Each option should be clearly clickable. Selected options should have a visual indicator (e.g., a checkmark).
  • Search: The search input should filter options in real-time as the user types.
  • "Select All" / "Deselect All": A prominent clickable element at the top of the option list. Its text should toggle based on whether all filtered items are currently selected or not.
  • Accessibility: Ensure basic keyboard navigation (Tab to focus, Arrow keys to navigate options, Enter/Space to select/deselect, Escape to close). ARIA attributes should be considered for screen reader compatibility.

Acceptance criteria

  • The MultiSelectDropdown component renders correctly with provided options.
  • Users can open/close the dropdown by clicking the input area or outside of it.
  • Typing in the search input filters the displayed options dynamically.
  • Clicking an option adds it to the selected items and displays it as a chip.
  • Clicking a selected option (or its checkmark) deselects it.
  • Clicking the 'remove' icon on a chip deselects that specific item.
  • The "Select All" / "Deselect All" option correctly selects all currently filtered options or deselects all selected options, respectively.
  • The component handles cases where no options match the search term by displaying a "No options found" message.
  • Keyboard navigation (focus, select, deselect, close) works as expected.
  • The component correctly passes the selectedOptions array to the onSelectionChange prop whenever the selection changes.

Constraints

Constraints & assumptions

  • Technology: React with TypeScript. Use functional components and React Hooks.
  • Styling: Basic CSS styling is sufficient; focus on functionality. No external UI frameworks (e.g., Material UI, Ant Design) are allowed.
  • Data Structure: Options will be an array of objects like { id: string | number, name: string }.
  • Performance: The component should handle up to 1000 options reasonably well, particularly for search filtering.
  • Environment: Assume a modern browser environment.

Out of scope

  • Asynchronous loading of options.
  • Persistence of selected items across sessions.
  • Drag-and-drop reordering of selected chips.
  • Complex validation logic.
  • Full ARIA role implementation for every interactive element (focus on basic keyboard navigation and common roles).

What interviewers evaluate

  • Component Design & Reusability: How well the component is structured, its props interface, and its potential for reuse.
  • State Management: Effective and clean management of component state (selected items, search term, dropdown visibility).
  • Functional Correctness: All features (select, deselect, search, select all/deselect all, keyboard navigation) work as specified.
  • Code Quality & TypeScript: Readability, maintainability, type safety, and error handling.
  • UI/UX & Accessibility: Implementation of a good user experience, including visual feedback and basic accessibility.

Loading editor...