Skip to content

[autocomplete] Guard against null inputRef during unmount#48617

Merged
mj12albert merged 3 commits into
mui:masterfrom
noam3127:autocomplete-null-ref
Jun 3, 2026
Merged

[autocomplete] Guard against null inputRef during unmount#48617
mj12albert merged 3 commits into
mui:masterfrom
noam3127:autocomplete-null-ref

Conversation

@noam3127
Copy link
Copy Markdown
Contributor

@noam3127 noam3127 commented Jun 3, 2026

Fixes a React 19 regression where inputRef.current is null when syncHighlightedIndexToDOM runs during unmount, causing Cannot read properties of null (reading 'removeAttribute'). React 19 cleans up refs before pending callbacks fire. Adds a null guard matching the existing listboxRef.current pattern. Originally fixed in #25311 but lost in the v9 rewrite.

@code-infra-dashboard
Copy link
Copy Markdown

code-infra-dashboard Bot commented Jun 3, 2026

Deploy preview

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

Bundle size

Bundle Parsed size Gzip size
@mui/material 🔺+25B(0.00%) 🔺+16B(+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


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

Comment thread packages/mui-material/src/useAutocomplete/useAutocomplete.js Outdated
Comment thread packages/mui-material/src/useAutocomplete/useAutocomplete.test.js Outdated
Co-authored-by: Albert Yu <albert@albertyu.co>
Signed-off-by: Albert Yu <albert@albertyu.co>
@mj12albert mj12albert added scope: autocomplete Changes related to the autocomplete. This includes ComboBox. type: regression A bug, but worse, it used to behave as expected. labels Jun 3, 2026
Copy link
Copy Markdown
Member

@mj12albert mj12albert left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @noam3127

@mj12albert mj12albert merged commit 9c5fb30 into mui:master Jun 3, 2026
20 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: regression A bug, but worse, it used to behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants