RFC: feat(picker): now leverages multiple selection #5383
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
RFC: Enhancing Picker Component with Multiple Selection
Summary
This RFC proposes enhancing the sp-picker component with improved multiple selection capabilities. The changes focus on providing a better user experience by keeping the overlay open during selection and implementing proper tag-based display of selected items.
Basic Multilple Selection:
With Icon Support
Motivation
The sp-picker component currently supports single selection operation, but lacks support for selecting multiple items - a common use case in form interfaces. Users frequently need to choose several options from a dropdown list without the friction of repeated interactions.
Implementing multiple selection in the sp-picker component addresses several key user needs:
Detailed Design
1. Keep Overlay Open During Multiple Selection
Modify the setValueFromItem method to check if the component is in multiple selection mode (this.multiple === true) and avoid closing the overlay when making selections:
2. Use sp-tag Component for Selected Items
Replace the current HTML-based rendering of selected items with proper sp-tag components:
3. Add Customizable Tag Rendering
Provide an API to customize the rendering of selected tags:
4. Customize Default Max Visible Options
You can customize the default maxOptionsVisible value for a better user experience:
Adoption Strategy
This change introduces new functionality through additional API properties that don't affect existing behavior. The new
multiple
property and its related APIs(maxOptionsVisible and renderTag)
are entirely opt-in and won't impact components using the standard single-selection behavior.The new multiple selection API is designed with the following principles:
Implementation Plan
This implementation can be completed in a single pull request as the changes are isolated to the Picker component.