Skip to content

[combobox] Fix popup input form submit - #4687

Merged
atomiks merged 4 commits into
mui:masterfrom
atomiks:codex/combobox-field-aware-popup-input-submit
Apr 30, 2026
Merged

atomiks merged 4 commits into
mui:masterfrom
atomiks:codex/combobox-field-aware-popup-input-submit

Conversation

@atomiks

@atomiks atomiks commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Fixes #4681

When a combobox uses the input-inside-popup pattern and renders Combobox.Input through field-aware Input, the popup search input inherited the surrounding Field.Root name and registered as the field control. That left the submitted field value empty until the interaction was repeated.

Changes

  • Render positioned popup inputs under the default no-op Field context so field-aware render targets stay search-only.
  • Keep the combobox's hidden form control responsible for field registration and submission.
  • Add regression coverage for a required combobox using render={<Input />} inside the popup.

@atomiks atomiks added component: combobox Changes related to the combobox component. type: bug It doesn't behave as expected. labels Apr 26, 2026 — with ChatGPT Codex Connector
@code-infra-dashboard

code-infra-dashboard Bot commented Apr 26, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+52B(+0.01%) 🔺+43B(+0.03%)

Details of bundle changes

Performance

Total duration: 1,158.73 ms ▼-47.56 ms(-3.9%) | Renders: 53 (+0) | Paint: 1,789.44 ms ▼-79.84 ms(-4.3%)

Test Duration Renders
Checkbox mount (500 instances) 80.97 ms 🔺+17.60 ms(+27.8%) 1 (+0)
Tooltip mount (300 contained roots) 58.35 ms 🔺+3.95 ms(+7.3%) 2 (+0)
Tabs mount (200 instances) 203.92 ms ▼-16.27 ms(-7.4%) 4 (+0)
Scroll Area mount (300 instances) 76.15 ms ▼-10.68 ms(-12.3%) 3 (+0)
Select mount (200 instances) 127.28 ms ▼-10.64 ms(-7.7%) 3 (+0)

...and 7 more. View full report

Details of benchmark changes


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

@netlify

netlify Bot commented Apr 26, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit acf1d53
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69f2b7a96cb0400008a3b9a1
😎 Deploy Preview https://deploy-preview-4687--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 marked this pull request as ready for review April 27, 2026 21:34

@flaviendelangle flaviendelangle left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

PR #4687 Review Summary — [combobox] Fix popup input form submit

Verdict: Ship it. The fix is correct, minimal, and well-scoped. No blocking issues.

Critical Issues

None found. Both agents independently confirmed the fix correctly addresses the root cause — useRegisterFieldControl overwriting the hidden combobox input's registration when a popup Combobox.Input renders the field-aware Input component.

Important Issues

1. Missing inverse-regression test for the non-popup branch (severity 9)

The fix is gated on hasPositionerParent at packages/react/src/combobox/input/ComboboxInput.tsx:491-497, but no test pins the non-popup case. If someone refactors and accidentally always wraps in DEFAULT_FIELD_ROOT_CONTEXT, <Combobox.Input render={<Input />} /> outside a popup would silently stop submitting. Suggest adding a test that renders the field-aware Input outside a popup and asserts name="country" is applied + form submits correctly.

2. Validation behavior with field-aware popup input is uncovered (severity 8)

The fix replaces the entire FieldRootContext, including validate, validation.commit, and validationMode. The existing test at line 5269 only covers bare <Combobox.Input />, not the render={<Input/>} variant. Suggest a test asserting Field.Error match="valueMissing" still surfaces on the trigger when popup input is field-aware.

3. Multi-select / chips path not exercised (severity 7)

Both agents flagged this independently. The most popular real-world combobox usage (multiple mode with chips) isn't covered with the popup field-aware input + form submit combination.

Suggestions

  • Tighten the new test's assertions — also assert the hidden serializer input has name="country" and the correct value (mirroring patterns at lines 4882, 4922). Currently only the negative assertion (not.toHaveAttribute('name')) is made.
  • Freeze DEFAULT_FIELD_ROOT_CONTEXT (and nested validityData / validation) so accidental writes — e.g. Field.Control writing validation.inputRef.current through the noop context — fail loudly in dev. Mirrors existing EMPTY_OBJECT / EMPTY_ARRAY guards.
  • Re-mount cycle test — the original bug "resolved on a second interaction," suggesting registration symbols can leak across mounts. A test that opens → closes → re-opens → selects → submits would lock this in.
  • No-Field.Root regression — quick render+submit with Combobox.Root name="country" and no Field.Root ancestor.

Strengths

  • Root cause correctly identified. The placement of the provider is sound: useFieldRootContext() is called at line 60 before the provider takes effect, so ComboboxInput's own focus/touch/validation logic still uses the outer field root — only the cloned child element sees the noop context.
  • Right scope — hasPositionerParent correctly excludes the inline-combobox case (where the visible input is the field control).
  • Refactor of the inline default to DEFAULT_FIELD_ROOT_CONTEXT follows project conventions (DEFAULT_FIELD_ROOT_STATE siblings) and is intentionally not exported from the package's index.ts — internal-only.
  • New test directly targets the user-visible failure (form data) rather than implementation details.
  • Adheres to project guidelines — no banned APIs introduced, no Chai/Sinon idioms, no unnecessary flushMicrotasks.

Recommended Action

  1. Optional: ask the PR author to add the non-popup branch regression test (severity 9) — it's cheap and catches the most likely future regression.
  2. Optional: add a multi-select + popup + field-aware Input form-submit test.
  3. Approve and merge — the remaining items are polish, not blockers.

@pkg-pr-new

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

commit: acf1d53

@atomiks
atomiks force-pushed the codex/combobox-field-aware-popup-input-submit branch from 7e68b45 to 4628412 Compare April 30, 2026 01:45
@atomiks
atomiks merged commit 1e7473e into mui:master Apr 30, 2026
6 checks passed
@atomiks
atomiks deleted the codex/combobox-field-aware-popup-input-submit branch April 30, 2026 02:10
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.

[combobox] form submit doesn't work when using combobox (input inside list pattern)

2 participants