Skip to content

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

Open
flaviendelangle wants to merge 1 commit into
mui:masterfrom
flaviendelangle:select-root-props-store-sync
Open

[select] Synchronize root props through the store#5589
flaviendelangle wants to merge 1 commit 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: 1e00549

@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%) 🔺+17B(+0.01%)

Details of bundle changes

Performance

Total duration: 1,075.57 ms -114.26 ms(-9.6%) | Renders: 76 (+0) | Paint: 1,731.62 ms -218.59 ms(-11.2%)

Test Duration Renders
Checkbox mount (500 instances) 59.91 ms ▼-17.25 ms(-22.4%) 1 (+0)
Dialog mount (300 instances) 21.95 ms ▼-11.05 ms(-33.5%) 1 (+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 1e00549
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a915d6e3d424a000822327a
😎 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.

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.

1 participant