Skip to content

test(react-list): add unit tests for useList_unstable and useListItem_unstable; fix as-prop operator precedence#36053

Draft
dmytrokirpa wants to merge 1 commit intomicrosoft:masterfrom
dmytrokirpa:test/list-hook-tests
Draft

test(react-list): add unit tests for useList_unstable and useListItem_unstable; fix as-prop operator precedence#36053
dmytrokirpa wants to merge 1 commit intomicrosoft:masterfrom
dmytrokirpa:test/list-hook-tests

Conversation

@dmytrokirpa
Copy link
Copy Markdown
Contributor

Summary

  • Adds unit tests for useList_unstable and useListItem_unstable
  • Fixes a latent operator-precedence bug in both hooks: props.as || navigationMode === 'composite' ? 'div' : DEFAULT_ROOT_EL_TYPE was being evaluated as (props.as || navigationMode === 'composite') ? 'div' : ...; corrected with explicit parentheses

Stack order (review in this order)

  1. This PR — hook unit tests + bug fix ← you are here
  2. feat(react-list): export useListContextValues_unstable and ListContextValues
  3. feat(react-headless-components-preview): headless List and ListItem components

Test plan

  • nx test react-list passes with new test files
  • as prop and navigationMode combinations produce the correct element type

🤖 Generated with Claude Code

…_unstable; fix operator precedence in as prop

Tests cover default state, selection modes, navigation modes, and the
composite-mode as-prop branching. The as-prop fix corrects a precedence
bug where `props.as || navigationMode === 'composite' ? 'div' : ...`
was evaluated as `(props.as || navigationMode === 'composite') ? ...`.

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

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-components
react-components: entire library
1.302 MB
325.338 kB
1.302 MB
325.338 kB
4 B
react-list
List
87.098 kB
25.756 kB
87.1 kB
25.756 kB
2 B
react-list
ListItem
110.887 kB
32.626 kB
110.889 kB
32.626 kB
2 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-components
react-components: Button, FluentProvider & webLightTheme
70.415 kB
19.963 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
237.29 kB
68.851 kB
react-components
react-components: FluentProvider & webLightTheme
43.63 kB
14.026 kB
react-portal-compat
PortalCompatProvider
8.386 kB
2.624 kB
react-timepicker-compat
TimePicker
109.674 kB
36.193 kB
🤖 This report was generated against 0392152eacf970d6d7063c12af84b20b7d45c8e1

@github-actions
Copy link
Copy Markdown

Pull request demo site: URL

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

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.default.chromium.png 654 Changed
vr-tests-react-components/CalendarCompat.multiDayView - Dark Mode.default.chromium.png 2172 Changed
vr-tests-react-components/CalendarCompat.multiDayView - High Contrast.default.chromium.png 2243 Changed
vr-tests-react-components/CalendarCompat.multiDayView.default.chromium_1.png 654 Changed
vr-tests-react-components/Charts-DonutChart 3 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Charts-DonutChart.Dynamic - Dark Mode.default.chromium.png 7530 Changed
vr-tests-react-components/Charts-DonutChart.Dynamic - RTL.default.chromium.png 5570 Changed
vr-tests-react-components/Charts-DonutChart.Dynamic.default.chromium.png 5581 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 958 Changed
vr-tests-react-components/Positioning.Positioning end.updated 2 times.chromium.png 624 Changed
vr-tests-react-components/ProgressBar converged 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/ProgressBar converged.Indeterminate + thickness - High Contrast.default.chromium.png 47 Changed
vr-tests-react-components/TagPicker 3 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/TagPicker.disabled - Dark Mode.disabled input hover.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.disabled input hover.chromium.png 677 Changed

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant