Repository navigation
[select][combobox] Add autoComplete prop for explicit browser autofill support - #4005
Conversation
commit: |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Greptile OverviewGreptile Summary
Confidence Score: 4/5
Important Files Changed
|
Is this only for Safari/Firefox? Chrome does look for Screen.Recording.2026-02-07.at.9.25.59.am.mov |
|
@atomiks Strange, that doesn't work for me in Chrome 144.0.7559.110. Happy to close this out if you think it's unnecessary. |
|
Chrome actually gives a warning when
So this does still look correct to add. @mattrothenberg this prop should also be added for Combobox as well — |
|
@atomiks excellent, will get this fixed ASAP |
|
@atomiks Updated. I named the internal prop |
Bundle size report
Check out the code infra dashboard for more information about this PR. |
1f0707c to
949f727
Compare
The Select component creates a hidden input for form submission, but without the autocomplete attribute, browsers don't know what data to autofill. This adds an autoComplete prop that gets passed to the hidden input element, enabling proper browser autofill functionality. Usage: ```tsx <Select.Root name="country" autoComplete="country"> ... </Select.Root> ```
…ll support Adds an autoComplete prop to Combobox.Root and Autocomplete.Root that gets passed to the hidden input element, enabling proper browser autofill functionality. Usage: ```tsx <Combobox.Root name="country" autoComplete="country"> ... </Combobox.Root> <Autocomplete.Root name="search" autoComplete="on"> ... </Autocomplete.Root> ```
949f727 to
94b06b8
Compare
autoComplete prop for explicit browser autofill support
94b06b8 to
54dcee2
Compare
|
Thanks for the contribution! Separate PR that adds the manual autofill demo — will amend it further: #3924 |
Summary
Adds an
autoCompleteprop toSelect.Rootthat gets passed to the hidden input element, enabling proper browser autofill functionality.Problem
The Select component creates a hidden input with the
nameattribute for form submission. However, without theautocompleteattribute, browsers don't recognize this input as a candidate for autofill.The existing autofill test verifies that the component handles autofill events when they occur (via
fireEvent.change), but withoutautocomplete, browsers don't trigger those events in the first place.It could be considered a regression from Material UI Select.
Solution
Add an
autoCompleteprop that passes through to the hidden input:This renders:
Changes
autoCompleteprop toSelectRootPropsinterface with JSDocautoCompleteto the hidden input elementReferences