feat: add selectable variant to List component#4817
Draft
ernst-dev wants to merge 2 commits into
Draft
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4817 +/- ##
==========================================
- Coverage 97.61% 97.61% -0.01%
==========================================
Files 952 952
Lines 30816 30891 +75
Branches 11318 11351 +33
==========================================
+ Hits 30081 30154 +73
- Misses 688 690 +2
Partials 47 47 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Adds an opt-in selectable variant to the
Listcomponent (SIM AWSUI-62052), enabling users to choose from a set of predefined options without reaching forTableorCardsfor simple selectable lists.New (fully backward-compatible) props:
selectionType?: 'single' | 'multi'— enables selection. When unset,Listbehaves exactly as before.selectedItems?: ReadonlyArray<T>— controlled selection (items matched by theidreturned fromrenderItem).onSelectionChange?: NonCancelableEventHandler<ListProps.SelectionChangeDetail<T>>— fires with the updatedselectedItems.isItemDisabled?: (item: T) => boolean— prevents selection of individual items.Behavior / accessibility:
selectionTypeis set (and the list is notsortable), the container renders asrole="listbox"witharia-multiselectablefor multi-select, and each item renders asrole="option"witharia-selected/aria-disabled.tabindex, Up/Down/Home/End to move focus, Space/Enter to toggle selection.multirenders a checkbox control (reusing the internalCheckboxIcon);singlerenders a radio control. Controls arearia-hiddensince state is conveyed viaaria-selected.sortable; when both are provided, sorting takes precedence.Test-utils:
ListItemWrapper.findSelectionControl()andListWrapper.findSelectedItems()added (dom + selectors).Related links, issue #, if available: AWSUI-62052
How has this been tested?
src/list/__tests__/list-selectable.test.tsx(11 tests): listbox/option roles,aria-multiselectable, controlled selection, single vs multi toggle semantics, disabled items, Space/Enter toggle, roving tabindex + arrow-key focus, and sortable-takes-precedence. All 31 List unit tests pass.pages/list/selectable.page.tsxdemonstrating controlled single and multi selection with disabled items.quick-build,eslint, andstylelintare green. Documenter API + test-utils snapshots regenerated.Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md.CONTRIBUTING.md.Security
checkSafeUrlfunction.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.