Repository navigation
[autocomplete] Fix popup input FormData submission - #4725
Conversation
commit: |
✅ Deploy Preview for base-ui ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Bundle size
PerformanceTotal duration: 1,190.46 ms 🔺+28.32 ms(+2.4%) | Renders: 53 (+0) | Paint: 1,853.86 ms 🔺+65.96 ms(+3.7%)
…and 7 more — details 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. |
|
The names here get a bit confusing.
Could we keep inputOwnsFormValue: selectionMode === 'none' && !hasPositionerParent,Then the hidden input branch reads: const hiddenInputOwnsNoneValue =
!inputOwnsFormValue ||
// Before the popup input mounts, trigger-control comboboxes still need
// the persistent hidden input to own native form submission.
(!inline && triggerElement != null && inputElement == null); |
That makes perfect sense !!. I'll revert Updating the PR shortly! Thanks for the review. |
atomiks
left a comment
There was a problem hiding this comment.
Thanks for the fix @lunaxislu
Fixes #4724.
Summary
nameselectionMode="none"values when the input is inside aPositionerFormDatapathsRoot cause
Autocomplete.Rootdelegates toAriaComboboxwithselectionMode="none", so the submitted field value is the input value rather than a selected value. Base UIForm.onFormSubmitcould read that value through the Field registry, but nativeFormDataonly reads named DOM controls.When the input is rendered inside the popup, the visible input is transient and can unmount after selection. The persistent hidden input existed, but it was unnamed for
selectionMode="none", so nativeFormDatahad no stable named control to read from.This complements #4687, which fixed the adjacent Combobox popup-input Field registration path.
Validation
pnpm test:jsdom AutocompleteRoot --no-watch -t "native FormData"pnpm test:chromium AutocompleteRoot --no-watch -t "native FormData"pnpm test:jsdom ComboboxRoot --no-watch -t "submits when input inside popup renders a field-aware input"pnpm test:chromium ComboboxRoot --no-watch -t "submits when input inside popup renders a field-aware input"pnpm test:jsdom AutocompleteRoot --no-watchpnpm typescriptpnpm prettierpnpm eslintgit diff --check