Skip to content

[composite] Fix list map tick canceling in StrictMode - #5862

Merged
atomiks merged 1 commit into
mui:masterfrom
atomiks:claude/priceless-cartwright-1ed2bd
Oct 5, 2026
Merged

atomiks merged 1 commit into
mui:masterfrom
atomiks:claude/priceless-cartwright-1ed2bd

Conversation

@atomiks

@atomiks atomiks commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

CompositeList forces a map rebuild by toggling a boolean state (setMapTick((tick) => !tick)). Under React 19 Strict Mode, two toggles can land in the same render and cancel out. That happens when the list re-renders in the same commit that mounts new items: the flush effect clears isDirtyRef while the first toggle is still queued, then Strict Mode replays the new items' refs and queues a second toggle. React sees no state change and skips the render, so the flush never runs and isDirtyRef stays true. Every later register/unregister then bails out early, and elementsRef stops syncing, so items that later mount or unmount without the list re-rendering drop out of keyboard navigation.

This PR uses an incrementing counter instead, so queued updates can't cancel each other. This only affects Strict Mode (dev) builds. The regression test replaces the list's items under Strict Mode, then hides one item without re-rendering the list.

@atomiks atomiks added type: bug It doesn't behave as expected. scope: all components Widespread work has an impact on almost all components. labels Oct 2, 2026
@atomiks
atomiks marked this pull request as ready for review October 2, 2026 04:05
@pkg-pr-new

pkg-pr-new Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@5862
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@5862
    

commit: 9741af8

@code-infra-dashboard

code-infra-dashboard Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 0B(0.00%) ▼-2B(0.00%)

Details of bundle changes

Performance

Total duration: 674.49 ms +1.96 ms(+0.3%) | Renders: 76 (+0) | Paint: 1,204.86 ms +10.61 ms(+0.9%)

No significant changes — details


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 9741af8
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6ac3114f258d1a0008813e20
😎 Deploy Preview https://deploy-preview-5862--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks
atomiks force-pushed the claude/priceless-cartwright-1ed2bd branch from be4de4e to 9741af8 Compare October 5, 2026 02:54
@atomiks
atomiks merged commit eb27741 into mui:master Oct 5, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: all components Widespread work has an impact on almost all components. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant