Skip to content

[autocomplete] Fix input value and clear#48263

Merged
mj12albert merged 2 commits intomui:masterfrom
mj12albert:autocomplete/fix-input-value-and-clear-2of5
Apr 14, 2026
Merged

[autocomplete] Fix input value and clear#48263
mj12albert merged 2 commits intomui:masterfrom
mj12albert:autocomplete/fix-input-value-and-clear-2of5

Conversation

@mj12albert
Copy link
Copy Markdown
Member

@mj12albert mj12albert commented Apr 10, 2026

Fixes #40099
Fixes #43458

1. Clear-on-escape breaks subsequent open-on-focus #43458

Demo: https://deploy-preview-48263--material-ui.netlify.app/material-ui/react-autocomplete/#creatable

  1. Select a film from the dropdown
  2. Click away to blur, then click back into the input — popup opens (confirms openOnFocus works)
  3. Press Escape — popup closes
  4. Press Escape again — value clears
  5. Click away to blur
  6. Click back into the input

With this fix: Popup opens on step 6

Without the fix: Popup doesn't open on step 6, the escape-clear breaks focusOnOpen afterwards


2. Controlled free solo input value doesn't clear #40099

Demo: https://stackblitz.com/edit/krui4i59-h253ekpy?file=src%2FDemo.tsx

  1. Select an option
  2. Click the external reset button

With this fix: input is cleared

Without the fix: input not cleared (stackblitz)

@mj12albert mj12albert added type: bug It doesn't behave as expected. scope: autocomplete Changes related to the autocomplete. This includes ComboBox. labels Apr 10, 2026
@mui-bot
Copy link
Copy Markdown

mui-bot commented Apr 10, 2026

Netlify deploy preview

https://deploy-preview-48263--material-ui.netlify.app/

Bundle size report

Bundle Parsed size Gzip size
@mui/material 🔺+43B(+0.01%) 🔺+21B(+0.01%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against f1cb316

@mj12albert mj12albert force-pushed the autocomplete/fix-input-value-and-clear-2of5 branch from 2e15ebf to 8e38a83 Compare April 13, 2026 00:13
@mj12albert mj12albert force-pushed the autocomplete/fix-input-value-and-clear-2of5 branch from 8e38a83 to f1cb316 Compare April 13, 2026 07:24
@mj12albert mj12albert marked this pull request as ready for review April 13, 2026 08:20
expect(textbox).toHaveFocus();

// Blur and re-focus: onOpen should be called (ignoreFocus was NOT set)
act(() => {
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.

would user.tab and user.tab({shift}) also work here?

@mj12albert mj12albert enabled auto-merge (squash) April 14, 2026 15:09
@code-infra-dashboard
Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@mui/material 🔺+43B(+0.01%) 🔺+20B(+0.01%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Deploy preview

https://deploy-preview-48263--material-ui.netlify.app/


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

@mj12albert mj12albert merged commit 22a9d00 into mui:master Apr 14, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: autocomplete Changes related to the autocomplete. This includes ComboBox. type: bug It doesn't behave as expected.

Projects

None yet

3 participants