[Autocomplete] 5.11.7 Introduced a Crashing Bug For This Configuration of Autocomplete #36114
Closed
2 tasks done
Labels
bug 🐛
Something doesn't work
component: autocomplete
This is the name of the generic UI component, not the React module!
regression
A bug, but worse
Duplicates
Latest version
Steps to reproduce 🕹
Link to live example:
https://codesandbox.io/s/compassionate-kapitsa-ouc9ml?file=/demo.tsx
Steps:
Cannot read properties of undefined (reading 'label')
at https://github.com/mui/material-ui/blob/master/packages/mui-base/src/AutocompleteUnstyled/useAutocomplete.js#L100 called from https://github.com/mui/material-ui/blob/master/packages/mui-base/src/AutocompleteUnstyled/useAutocomplete.js#L473Current behavior 😯
I expect the Autocomplete to not crash if I select the wrong option in the dropdown and immediately try to delete it
Expected behavior 🤔
No crashing, the selected option is deleted
Context 🔦
The three options specified in the CodeSandbox all need to be present for this issue to trigger:
multiple
,disableCloseOnSelect
, andfilterSelectedOptions
. This issue was introduced in 5.11.7 by this PR: #35735The source trigger is
getOptionLabel(value[i])
here: https://github.com/mui/material-ui/blob/master/packages/mui-base/src/AutocompleteUnstyled/useAutocomplete.js#L473When you delete the option,
value
is now[]
and sovalue[i]
is undefined. When fed togetOptionLabel
, it crashes because it expects option to not be undefined.Your environment 🌎
npx @mui/envinfo
The text was updated successfully, but these errors were encountered: