Skip to content

[autocomplete] Prevent crash when rendering cached grouped options#48788

Open
atharva3333 wants to merge 3 commits into
mui:masterfrom
atharva3333:autocomplete-groupBy-regression-fix
Open

[autocomplete] Prevent crash when rendering cached grouped options#48788
atharva3333 wants to merge 3 commits into
mui:masterfrom
atharva3333:autocomplete-groupBy-regression-fix

Conversation

@atharva3333

Copy link
Copy Markdown
Contributor

Fixes #48692

Summary

Fixes a regression introduced by #48327 where cached ungrouped options can be rendered after groupBy becomes active.

The grouped rendering path assumed every cached entry had the grouped { group, options } shape and attempted to access option.options, causing a runtime error when cached raw options were encountered.

This change guards the grouped rendering path against cached raw options and adds a regression test covering the reported scenario.

@code-infra-dashboard

code-infra-dashboard Bot commented Jul 7, 2026

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-48788--material-ui.netlify.app/
QR code for https://deploy-preview-48788--material-ui.netlify.app/

Bundle size

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

@ZeeshanTamboli
ZeeshanTamboli requested a review from mj12albert July 8, 2026 06:39
@ZeeshanTamboli ZeeshanTamboli added type: bug It doesn't behave as expected. scope: autocomplete Changes related to the autocomplete. This includes ComboBox. labels Jul 8, 2026
@ZeeshanTamboli ZeeshanTamboli changed the title [Autocomplete] Prevent crash when rendering cached grouped options [autocomplete] Prevent crash when rendering cached grouped options Jul 8, 2026

@ZeeshanTamboli ZeeshanTamboli left a comment

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.

This works but the fix is a defensive workaround rather than fixing the root issue. With this, when groupBy is active, Autocomplete will silently render a raw option through the ungrouped path. If groupBy is enabled, the list renderer should receive grouped option objects only.

@ZeeshanTamboli ZeeshanTamboli added type: regression A bug, but worse, it used to behave as expected. and removed type: bug It doesn't behave as expected. labels Jul 13, 2026
@atharva3333

Copy link
Copy Markdown
Contributor Author

Sure, I will try fixing the root cause

@ZeeshanTamboli

Copy link
Copy Markdown
Member

Sure, I will try fixing the root cause

@atharva3333 Did you find a solution?

@atharva3333

Copy link
Copy Markdown
Contributor Author

@atharva3333 Did you find a solution?

Not yet

@ZeeshanTamboli ZeeshanTamboli left a comment

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.

I believe it is not an issue. I have posted a comment: #48692 (comment). Let's wait for the author's response.

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.

Autocomplete groupBy breaks after creating a new option when all existing options are selected (regression in 7.3.11)

2 participants