Skip to content

[select][combobox] Add autoComplete prop for explicit browser autofill support - #4005

Merged
atomiks merged 6 commits into
mui:masterfrom
mattrothenberg:feat/select-autocomplete
Feb 9, 2026
Merged

atomiks merged 6 commits into
mui:masterfrom
mattrothenberg:feat/select-autocomplete

Conversation

@mattrothenberg

@mattrothenberg mattrothenberg commented Feb 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds an autoComplete prop to Select.Root that gets passed to the hidden input element, enabling proper browser autofill functionality.

Problem

The Select component creates a hidden input with the name attribute for form submission. However, without the autocomplete attribute, 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 without autocomplete, browsers don't trigger those events in the first place.

It could be considered a regression from Material UI Select.

Solution

Add an autoComplete prop that passes through to the hidden input:

<Select.Root name="country" autoComplete="country">
  <Select.Trigger>
    <Select.Value />
  </Select.Trigger>
  ...
</Select.Root>

This renders:

<input name="country" autocomplete="country" ... />

Changes

  • Add autoComplete prop to SelectRootProps interface with JSDoc
  • Destructure and pass autoComplete to the hidden input element
  • Add test to verify the attribute is passed through

References

@pkg-pr-new

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

commit: 54dcee2

@netlify

netlify Bot commented Feb 6, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 54dcee2
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/698962580e4535000833134b
😎 Deploy Preview https://deploy-preview-4005--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@greptile-apps

greptile-apps Bot commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

  • Adds an autoComplete prop to Select.Root and forwards it to the hidden <input> used for form submission.
  • Extends SelectRootProps with JSDoc pointing to the MDN autocomplete attribute docs.
  • Adds a unit test intended to verify autocomplete is rendered on the hidden input (but the query strategy may be unreliable).

Confidence Score: 4/5

  • This PR is largely safe to merge, but the new test should be adjusted to avoid an unreliable role query for the hidden input.
  • Core change is a straightforward prop passthrough to a hidden input. Main concern is test stability: querying the hidden input via role 'textbox' can be environment-dependent due to aria-hidden/implicit roles.
  • packages/react/src/select/root/SelectRoot.test.tsx

Important Files Changed

Filename Overview
packages/react/src/select/root/SelectRoot.tsx Adds autoComplete prop to SelectRootProps and forwards it to the hidden input used for form submission/autofill.
packages/react/src/select/root/SelectRoot.test.tsx Adds a test asserting autocomplete attribute is set on the hidden input, but the test may select the wrong element by role ('textbox') if the hidden input isn't exposed with that role in the test environment.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@oliviertassinari oliviertassinari added component: select Changes related to the select component. docs Improvements or additions to the documentation. labels Feb 6, 2026
@oliviertassinari oliviertassinari changed the title feat(select): add autoComplete prop for browser autofill support [select] Add autoComplete prop for browser autofill support Feb 6, 2026
@oliviertassinari oliviertassinari removed the docs Improvements or additions to the documentation. label Feb 6, 2026
@atomiks

atomiks commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

The Select component creates a hidden input with the name attribute for form submission. However, without the autocomplete attribute, 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 without autocomplete, browsers don't trigger those events in the first place.

Is this only for Safari/Firefox?

Chrome does look for name, as the autofill demo works in Chrome already for Select:

Screen.Recording.2026-02-07.at.9.25.59.am.mov

@mattrothenberg

mattrothenberg commented Feb 6, 2026 •

Copy link
Copy Markdown
Contributor Author

@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.

@atomiks

atomiks commented Feb 8, 2026 •

Copy link
Copy Markdown
Contributor

Chrome actually gives a warning when autocomplete is missing when autofill recognizes the id/name of the field:

A form field has an id or name attribute that the browser's autofill recognizes. However, it doesn't have an autocomplete attribute assigned. This might prevent the browser from correctly autofilling the form.

So this does still look correct to add.

@mattrothenberg this prop should also be added for Combobox as well — AriaCombobox has an autoComplete prop but only for Autocomplete's public API which calls it mode. Combobox (public) omits it. Both could still have a (public) prop called autoComplete which forwards to the hidden input

@mattrothenberg

Copy link
Copy Markdown
Contributor Author

@atomiks excellent, will get this fixed ASAP

@mattrothenberg

Copy link
Copy Markdown
Contributor Author

@atomiks Updated. I named the internal prop formAutoComplete to distinguish it from the existing ARIA autoComplete prop in AriaCombobox. Feel free to tweak the last two commits if I did it wrong!

@mui-bot

mui-bot commented Feb 9, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+121B(+0.03%) 🔺+21B(+0.02%)

Details of bundle changes


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

@atomiks
atomiks force-pushed the feat/select-autocomplete branch from 1f0707c to 949f727 Compare February 9, 2026 04:05
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>
```
@atomiks
atomiks force-pushed the feat/select-autocomplete branch from 949f727 to 94b06b8 Compare February 9, 2026 04:08
@atomiks atomiks added component: autocomplete Changes related to the autocomplete component. component: combobox Changes related to the combobox component. type: new feature Expand the scope of the product to solve a new problem. labels Feb 9, 2026
@atomiks atomiks changed the title [select] Add autoComplete prop for browser autofill support [select][combobox] Add autoComplete prop for explicit browser autofill support Feb 9, 2026
@atomiks
atomiks force-pushed the feat/select-autocomplete branch from 94b06b8 to 54dcee2 Compare February 9, 2026 04:28
@atomiks atomiks removed the component: autocomplete Changes related to the autocomplete component. label Feb 9, 2026
@atomiks
atomiks merged commit 72995b0 into mui:master Feb 9, 2026
8 checks passed
@atomiks

atomiks commented Feb 9, 2026

Copy link
Copy Markdown
Contributor

Thanks for the contribution!

Separate PR that adds the manual autofill demo — will amend it further: #3924

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. component: select Changes related to the select component. type: new feature Expand the scope of the product to solve a new problem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants