Skip to content

[select] Synchronize root props through the store - #5589

Merged
flaviendelangle merged 3 commits into
mui:masterfrom
flaviendelangle:select-root-props-store-sync
Sep 23, 2026
Merged

flaviendelangle merged 3 commits into
mui:masterfrom
flaviendelangle:select-root-props-store-sync

Conversation

@flaviendelangle

Copy link
Copy Markdown
Member

Select still sends root values such as disabled, readOnly, and required through a separate React context after #5582. Combobox sends the equivalent values through its selector-based store. This PR makes Select follow the Combobox model.

What changed

  • Move disabled, readOnly, required, multiple, highlightItemOnHover, and itemProps into the Select store.
  • Remove SelectRootPropsContext.
  • Let the trigger, list, popup, and items subscribe only to the values they use.
  • Seed itemProps before the first descendant render and synchronize later root updates in the existing atomic store transaction.
  • Extend the store tests to cover disabled synchronization and its commit timing.

Trade-off

The removed context propagated new root props during the same render. Descendant ref callbacks therefore saw an updated disabled value during that commit.

store.useSyncedValues publishes changes from the root's layout effect, after descendant ref callbacks have run. Store subscribers then rerender before the browser paints, so the rendered DOM and interactions after the commit use the new value. There is one narrower window: if a consumer performs an imperative interaction from a descendant ref callback during the exact commit that changes disabled from false to true, the handler still sees false and can commit a selection. The updated characterization test pins this case.

This gives up Select's stronger same-commit guarantee in that ref-callback window. In return, changing one root value no longer invalidates every consumer of the combined context, including every mounted item, and Select now has the same propagation semantics as Combobox. Keeping synchronous ref-callback behavior would require retaining a separate context with its broader rerender fan-out, or changing the shared store synchronization model for both components.

Verification

  • pnpm test:jsdom Select --no-watch (506 passed, 71 skipped)
  • pnpm test:chromium Select --no-watch (558 passed, 19 skipped)
  • pnpm typescript
  • pnpm eslint
  • pnpm prettier

@pkg-pr-new

pkg-pr-new Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

commit: 9ab42e0

@flaviendelangle flaviendelangle self-assigned this Aug 28, 2026
@flaviendelangle flaviendelangle added component: select Changes related to the select component. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. discussion labels Aug 28, 2026
@code-infra-dashboard

code-infra-dashboard Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+195B(+0.04%) 🔺+47B(+0.03%)

Details of bundle changes

Performance

Total duration: 1,031.04 ms -94.18 ms(-8.4%) | Renders: 76 (+0) | Paint: 1,698.70 ms -184.73 ms(-9.8%)

Test Duration Renders
Slider mount (300 instances) 90.99 ms ▼-23.27 ms(-20.4%) 2 (+0)
Combobox open — 500 items 22.47 ms ▼-6.49 ms(-22.4%) 4 (+0)

13 tests within noise — details


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

@flaviendelangle

Copy link
Copy Markdown
Member Author

@atomiks maybe you have more insight about why the Select and the Combobox were not behaving the same way here.

@netlify

netlify Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 9ab42e0
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6ab372804d72de00089be507
😎 Deploy Preview https://deploy-preview-5589--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.

@flaviendelangle
flaviendelangle merged commit f4f7c86 into mui:master Sep 23, 2026
24 checks passed
@flaviendelangle
flaviendelangle deleted the select-root-props-store-sync branch September 23, 2026 06:46
michaldudak added a commit to michaldudak/base-ui that referenced this pull request Sep 23, 2026
Resolves the SelectRoot import conflict with mui#5589, which removed the
root props context: keep the HighlightItemTarget import alongside
master's reduced context import.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: select Changes related to the select component. discussion type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants