Repository navigation
[combobox] Fix popup input form submit - #4687
Conversation
Bundle size
PerformanceTotal duration: 1,158.73 ms ▼-47.56 ms(-3.9%) | Renders: 53 (+0) | Paint: 1,789.44 ms ▼-79.84 ms(-4.3%)
...and 7 more. View full report Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
flaviendelangle
left a comment
There was a problem hiding this comment.
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 nestedvalidityData/validation) so accidental writes — e.g.Field.Controlwritingvalidation.inputRef.currentthrough the noop context — fail loudly in dev. Mirrors existingEMPTY_OBJECT/EMPTY_ARRAYguards. - 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 noField.Rootancestor.
Strengths
- Root cause correctly identified. The placement of the provider is sound:
useFieldRootContext()is called at line 60 before the provider takes effect, soComboboxInput's own focus/touch/validation logic still uses the outer field root — only the cloned child element sees the noop context. - Right scope —
hasPositionerParentcorrectly excludes the inline-combobox case (where the visible input is the field control). - Refactor of the inline default to
DEFAULT_FIELD_ROOT_CONTEXTfollows project conventions (DEFAULT_FIELD_ROOT_STATEsiblings) and is intentionally not exported from the package'sindex.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
- 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.
- Optional: add a multi-select + popup + field-aware Input form-submit test.
- Approve and merge — the remaining items are polish, not blockers.
commit: |
7e68b45 to
4628412
Compare
Fixes #4681
When a combobox uses the input-inside-popup pattern and renders
Combobox.Inputthrough field-awareInput, the popup search input inherited the surroundingField.Rootname and registered as the field control. That left the submitted field value empty until the interaction was repeated.Changes
render={<Input />}inside the popup.