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:
- Core Selection: Allow users to select multiple options from a predefined list.
- Display Selected Tags: As options are selected, display them as interactive, removable tags outside the dropdown input area.
- Search & Filter: Implement a real-time search functionality within the dropdown to filter the available options based on user input.
- Debounced Search: Optimize the search input by debouncing the filtering logic to prevent excessive re-renders and improve performance, especially with large datasets.
- Bulk Actions: Provide "Select All" and "Clear All" actions within the dropdown menu to manage selections efficiently.
- 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.