Skip to content

[combo-box] Fix applying data-readOnly for ComboboxTrigger - #5418

Merged
sai6855 merged 6 commits into
mui:masterfrom
sai6855:data-read-combobo
Aug 17, 2026
Merged

sai6855 merged 6 commits into
mui:masterfrom
sai6855:data-read-combobo

Conversation

@sai6855

@sai6855 sai6855 commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

readOnly was missing from the trigger's state, so the documented data-readonly style hook never rendered, even though the sibling Combobox.Input already emits it. Added readOnly to the state plus a test.


const state: ComboboxTriggerState = {
...fieldState,
readOnly,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

data-readOnly wasn't added when root was set to readOnly. adding readOnly state here fixed the issue

@sai6855 sai6855 added type: bug It doesn't behave as expected. component: combobox Changes related to the combobox component. labels Aug 5, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 5, 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@5418
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@5418
    

commit: 1acfee1

@code-infra-dashboard

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

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+11B(0.00%) 🔺+3B(0.00%)

Details of bundle changes

Performance

Total duration: 1,232.01 ms -78.91 ms(-6.0%) | Renders: 78 (+0) | Paint: 1,925.71 ms -116.82 ms(-5.7%)

Test Duration Renders
Tabs mount (200 instances) 181.75 ms ▼-65.91 ms(-26.6%) 3 (+0)
Combobox open — 500 items 33.60 ms ▼-9.49 ms(-22.0%) 4 (+0)

13 tests within noise — details


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

@netlify

netlify Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Built without sensitive environment variables

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the Combobox.Trigger state so the readOnly flag is reflected in its state-driven data attributes (enabling the data-readonly styling hook), aligning it with how other components expose readOnly for styling.

Changes:

  • Adds readOnly to ComboboxTrigger’s computed state so useRenderElement can apply data-readonly.
  • Extends ComboboxTriggerState with a readOnly field.
  • Adds a regression test asserting data-readonly is present only when readOnly is true.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/react/src/combobox/trigger/ComboboxTrigger.tsx Includes readOnly in the trigger state so the data-readonly style hook is applied correctly.
packages/react/src/combobox/trigger/ComboboxTrigger.test.tsx Adds coverage to ensure data-readonly toggles with the readOnly prop.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sai6855
sai6855 marked this pull request as ready for review August 5, 2026 07:58
@sai6855

sai6855 commented Aug 10, 2026

Copy link
Copy Markdown
Member Author

Ping @atomiks

@atomiks

atomiks commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

PR review

One merge-blocking public API mismatch remains. The runtime fix is mutation-proven and focused tests pass, but the shared Autocomplete alias was not updated.

Bugs (1)

1. 🔴 Keep the Autocomplete trigger state type in sync

Location: packages/react/src/autocomplete/trigger/AutocompleteTrigger.tsx:16

export const AutocompleteTrigger = ComboboxTrigger as AutocompleteTrigger;

export interface AutocompleteTriggerState extends FieldRootState {
  // `readOnly` is missing
}

Autocomplete.Trigger aliases Combobox.Trigger, so this PR now supplies readOnly to both components’ runtime state. However, the exported Autocomplete state type—and generated Autocomplete documentation—still omits it.

Failure scenario: A consumer styling <Autocomplete.Trigger> with className={(state) => state.readOnly ? ...} receives TS2339: Property 'readOnly' does not exist on type 'AutocompleteTriggerState', even though the runtime state and data-readonly attribute support it. A direct public-type probe reproduced this error.

Fix: Add readOnly: boolean to AutocompleteTriggerState, regenerate the Autocomplete API docs, and cover the shared alias in a public-type test.

Verdict

Request changes - the shared runtime component and its exported Autocomplete state contract are inconsistent.


🤖 Review generated with Codex

@sai6855

sai6855 commented Aug 10, 2026

Copy link
Copy Markdown
Member Author

@atomiks Done, updated type here 9439b90 1acfee1

@sai6855
sai6855 merged commit 79ea422 into mui:master Aug 17, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: combobox Changes related to the combobox component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants