Overview
As part of enhancing the product discovery experience on Amazon, we're building a new generation of dynamic filtering components. This problem focuses on creating a robust and accessible multi-select dropdown that allows users to quickly filter large sets of product attributes. A well-designed, performant, and intuitive filtering mechanism is crucial for improving customer satisfaction and conversion rates on complex product pages.
What you need to do / Task
Your primary task is to implement a reusable MultiSelectDropdown React component that fulfills the following requirements:
- Core Selection Logic: Implement the functionality to select and deselect multiple options from a predefined list.
- Dropdown Toggle: The dropdown panel should open and close when its trigger element is clicked.
- Option Display: Display the available options within the dropdown, each with a checkbox to indicate its selection status.
- Search/Filter: Include an input field within the dropdown panel that allows users to filter the displayed options dynamically based on a search term. The search should be case-insensitive.
- "Select All" / "Clear All": Provide controls within the dropdown to select all currently filtered options or clear all selected options.
- Display Selected Items: Outside the dropdown trigger, display the currently selected items as "tags" or "pills". Each tag should be dismissible (clickable to deselect the item).
- Empty State: Handle cases where no options are available or no search results are found.
UI/UX expectations
- Layout: The component should consist of a primary trigger (e.g., a button or input-like element) that, when clicked, reveals a dropdown panel. The panel should contain a search input, a list of selectable options (with checkboxes), and "Select All" / "Clear All" buttons. Selected items should appear as dismissible tags below the trigger.
- Interactions:
- Clicking the trigger toggles the dropdown's visibility.
- Clicking an option's checkbox (or the option text itself) toggles its selection status.
- Typing in the search input immediately filters the options list.
- Clicking "Select All" selects all currently visible/filtered options.
- Clicking "Clear All" deselects all currently selected options (not just filtered ones).
- Clicking a selected item's dismiss button (or the tag itself) deselects that item.
- Clicking outside the dropdown panel should close it.
- Accessibility:
- The component must be navigable via keyboard (e.g., Tab to focus trigger, Arrow keys to navigate options within the open dropdown, Enter/Space to select/deselect).
- Appropriate ARIA attributes (e.g.,
aria-haspopup, aria-expanded, aria-controls, aria-selected, role="listbox", role="option") should be used to convey the component's state and structure to assistive technologies.
Acceptance criteria
- Dropdown opens/closes correctly on trigger click and outside click.
- Individual options can be selected and deselected.
- Search input filters options list in real-time.
- "Select All" button selects all options matching the current search filter.
- "Clear All" button deselects all currently selected options.
- Selected options are displayed as dismissible tags below the component.
- Keyboard navigation (Tab, Arrow keys, Enter, Space, Escape) is fully functional for all interactive elements.
- All interactive elements have appropriate ARIA attributes for accessibility.
- The component gracefully handles empty option lists and no search results.