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:
- Develop a
MultiSelectDropdown React component that is generic and reusable.
- Accepts an array of options, where each option is an object with at least
id (unique identifier) and name (display text) properties.
- Allows users to select multiple options. Selected options should be visually represented as "chips" or "tags" within the dropdown's input area.
- 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.
- Support individual deselection of items by clicking a 'remove' icon on their respective chips.
- 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).
- 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.