Frontend School

Advanced Multi-Select Tag Filter

Machine Coding
hard

Advanced Multi-Select Tag Filter

Hard
React
UI
Multi-Select
Dropdown
Machine Coding
Accessibility
Debounce
STAFF

Overview

Sharechat's product suite relies heavily on robust filtering mechanisms, whether for content discovery, user segmentation, or internal moderation tools. A common requirement is an intuitive and performant multi-select dropdown to handle various categories, tags, or user groups. This problem challenges you to build a feature-rich multi-select component that not only handles core selection logic but also incorporates advanced UX patterns and performance considerations crucial for a STAFF-level engineering role.

What you need to do / Task

Your goal is to implement a reusable MultiSelectDropdown React component with the following features:

  1. Core Selection: Allow users to select multiple options from a predefined list.
  2. Display Selected Tags: As options are selected, display them as interactive, removable tags outside the dropdown input area.
  3. Search & Filter: Implement a real-time search functionality within the dropdown to filter the available options based on user input.
  4. Debounced Search: Optimize the search input by debouncing the filtering logic to prevent excessive re-renders and improve performance, especially with large datasets.
  5. Bulk Actions: Provide "Select All" and "Clear All" actions within the dropdown menu to manage selections efficiently.
  6. Keyboard Accessibility: Ensure basic keyboard navigation:
    • ArrowUp/ArrowDown: Navigate through the visible options in the dropdown list.
    • Enter: Select/deselect the currently highlighted option.
    • Escape: Close the dropdown menu.

UI/UX expectations

  • The component should visually resemble a standard dropdown: an input field that, when focused or clicked, reveals a list of options.
  • Selected items in the dropdown list should have a clear visual indicator (e.g., a checkbox or distinct background).
  • The search input should be integrated seamlessly at the top of the dropdown list.
  • "Select All" and "Clear All" actions should be clearly visible and functional when the dropdown is open.
  • Selected options should appear as distinct, compact tags below the main dropdown input. Each tag should have a clickable 'X' icon to remove it.
  • Handle cases where no search results are found (e.g., display "No options found").
  • Ensure the component is reasonably styled for readability and basic usability (functional styles only, no need for elaborate design system integration).

Acceptance criteria

  • The dropdown toggles open/closed correctly upon interaction with the input or clicking outside.
  • Users can select and deselect individual options.
  • Selected options are displayed as removable tags outside the dropdown.
  • Clicking the 'X' on a tag removes the corresponding selection.
  • Typing in the search input dynamically filters the options list.
  • The search filtering logic is debounced (e.g., by 300-500ms).
  • "Select All" selects all currently filtered options (if a search is active) or all options (if no search).
  • "Clear All" deselects all currently selected options.
  • Keyboard ArrowUp/ArrowDown navigates focus within the dropdown options.
  • Keyboard Enter selects/deselects the focused option.
  • Keyboard Escape closes the dropdown.
  • No console errors.

Constraints

Constraints & assumptions

  • You must use React (functional components and hooks).
  • The options data will be provided as a simple array of objects, each with id (unique string/number) and name (string).
  • Assume a maximum of 500-1000 options for performance considerations.
  • No external UI component libraries (e.g., Material UI, Ant Design) are allowed; build the component from scratch.
  • Styling can be minimal but should clearly differentiate interactive elements and states.
  • The component should manage its own internal state.

Out of scope

  • Full ARIA attribute compliance (beyond basic keyboard navigation).
  • Persistence of selected values across page reloads.
  • Asynchronous loading indicators for options (mock data is sufficient).
  • Custom rendering of options or tags.

What interviewers evaluate

  • Component Design & Architecture: How well the component is structured, its reusability, and separation of concerns.
  • State Management & Performance: Efficient use of React state, handling of re-renders, and implementation of debouncing.
  • UI/UX & Edge Cases: Attention to detail in user interaction, visual feedback, and handling of various scenarios (e.g., empty search, no options).
  • Accessibility & Robustness: Implementation of keyboard navigation and overall code quality.

Loading editor...