Skip to content

feat(react-list): add useListBase_unstable and useListItemBase_unstable hooks#35821

Draft
dmytrokirpa wants to merge 3 commits intomasterfrom
feat/react-list-base-hooks
Draft

feat(react-list): add useListBase_unstable and useListItemBase_unstable hooks#35821
dmytrokirpa wants to merge 3 commits intomasterfrom
feat/react-list-base-hooks

Conversation

@dmytrokirpa
Copy link
Contributor

Summary

  • Adds ListBaseProps / ListBaseState as type aliases for ListProps / ListState (List has no design-specific props to omit)
  • Adds ListItemBaseProps / ListItemBaseState as type aliases for ListItemProps / ListItemState (ListItem also has no design-specific props)
  • Adds useListBase_unstable hook containing the full List component logic:
    • ARIA: role calculation (list/listbox/grid based on navigation/selection mode), aria-multiselectable
    • Keyboard navigation: useArrowNavigationGroup for vertical arrow key navigation
    • Selection: controlled/uncontrolled selection state via useControllableState, useListSelection
    • Validation: validateListItem for dev-mode checks on proper element types and roles
    • Slot structure: root element (ul/div/ol depending on navigationMode)
  • Adds useListItemBase_unstable hook containing the full ListItem component logic:
    • Keyboard handling: Enter (trigger action), Space (toggle selection or trigger action), Arrow keys (composite navigation escape/mover events)
    • Selection: click handler, checkmark checkbox slot with onChange
    • Focus management: useFocusableGroup, useArrowNavigationGroup (horizontal for composite mode)
    • ARIA: aria-selected, aria-disabled, tabIndex, role propagated from list context
    • Action event: createListItemActionEvent dispatching
  • Refactors useList_unstable and useListItem_unstable to delegate directly to base hooks
  • Exports all new types and hooks from package index

Note on design props

List and ListItem have no design-specific props (no appearance, size, or shape). The base types are therefore equivalent to the full types. This follows the established pattern for consistency across the component library, enabling future styling customization.

Test plan

  • Verify TypeScript types compile correctly
  • Verify useList_unstable still works as before (behavior unchanged)
  • Verify useListItem_unstable still works as before (behavior unchanged)
  • Verify useListBase_unstable handles all selection modes
  • Verify useListItemBase_unstable handles all keyboard interactions
  • Verify new exports are available from package index

🤖 Generated with Claude Code

dmytrokirpa and others added 2 commits March 5, 2026 12:05
…le hooks

Adds base types and hooks for both List and ListItem components:
- ListBaseProps/ListBaseState: type aliases for ListProps/ListState (no design props to omit)
- ListItemBaseProps/ListItemBaseState: type aliases for ListItemProps/ListItemState (no design props to omit)
- useListBase_unstable: handles ARIA roles (aria-multiselectable), keyboard navigation (arrow keys),
  selection state (controlled/uncontrolled), validateListItem, and slot structure
- useListItemBase_unstable: handles keyboard handling (Enter/Space/Arrow keys), selection, focus management
  (focusableGroup, arrowNavigation tabster), checkmark slot with onChange, and ARIA attributes
- Refactors styled hooks to delegate to base hooks

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dmytrokirpa dmytrokirpa force-pushed the feat/react-list-base-hooks branch from 85e0559 to 5445c2e Compare March 5, 2026 11:05
@dmytrokirpa dmytrokirpa changed the base branch from experimental/component-base-hooks to master March 5, 2026 11:05
@github-actions
Copy link

github-actions bot commented Mar 5, 2026

Pull request demo site: URL

@@ -0,0 +1,7 @@
{
Copy link

@github-actions github-actions bot Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵🏾‍♀️ visual changes to review in the Visual Change Report

vr-tests-react-components/CalendarCompat 4 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/CalendarCompat.multiDayView - High Contrast.default.chromium.png 1236 Changed
vr-tests-react-components/CalendarCompat.multiDayView - Dark Mode.default.chromium.png 1107 Changed
vr-tests-react-components/CalendarCompat.multiDayView - RTL.default.chromium.png 495 Changed
vr-tests-react-components/CalendarCompat.multiDayView.default.chromium_1.png 403 Changed
vr-tests-react-components/Charts-DonutChart 3 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Charts-DonutChart.Dynamic.default.chromium.png 5581 Changed
vr-tests-react-components/Charts-DonutChart.Dynamic - RTL.default.chromium.png 5570 Changed
vr-tests-react-components/Charts-DonutChart.Dynamic - Dark Mode.default.chromium.png 7530 Changed
vr-tests-react-components/Menu Converged - submenuIndicator slotted content 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Menu Converged - submenuIndicator slotted content.default - RTL.submenus open.chromium.png 404 Changed
vr-tests-react-components/Positioning 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Positioning.Positioning end.chromium.png 139 Changed
vr-tests-react-components/Positioning.Positioning end.updated 2 times.chromium.png 516 Changed
vr-tests-react-components/TagPicker 3 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/TagPicker.disabled - Dark Mode.chromium.png 658 Changed
vr-tests-react-components/TagPicker.disabled - High Contrast.disabled input hover.chromium.png 1319 Changed
vr-tests-react-components/TagPicker.disabled - RTL.disabled input hover.chromium.png 635 Changed

There were 4 duplicate changes discarded. Check the build logs for more information.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Mar 5, 2026

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-components
react-components: entire library
1.292 MB
323.107 kB
1.292 MB
323.139 kB
36 B
32 B
react-list
List
87.11 kB
25.762 kB
87.124 kB
25.767 kB
14 B
5 B
react-list
ListItem
110.695 kB
32.627 kB
110.709 kB
32.627 kB
14 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-components
react-components: Button, FluentProvider & webLightTheme
70.397 kB
19.96 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
236.537 kB
68.697 kB
react-components
react-components: FluentProvider & webLightTheme
43.612 kB
14.022 kB
react-portal-compat
PortalCompatProvider
8.386 kB
2.624 kB
react-timepicker-compat
TimePicker
108.174 kB
35.695 kB
🤖 This report was generated against ace36179073ac4600a3635304a0941bd7dcda21d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant