[Autocomplete] regression in behavior for freeSolo Autocomplete with custom Popper/Paper and no options #44048
Labels
bug 🐛
Something doesn't work
component: autocomplete
This is the name of the generic UI component, not the React module!
package: material-ui
Specific to @mui/material
regression
A bug, but worse
Steps to reproduce
Old behavior: https://stackblitz.com/edit/react-ouzbqw-wbhjow?file=Demo.tsx,package.json
New behavior: https://stackblitz.com/edit/react-ouzbqw-vpfhhc?file=Demo.tsx,package.json'
Steps:
[]
SET DEFAULT OPTIONS
to reset and try againCurrent behavior
When options prop is set to
[]
the Autocomplete Popper is no longer rendered. The Autocomplete's state still considers itself open and the onClose handler is not called. Any custom Popper/Paper used in the Autocomplete will not be rendered.Expected behavior
The Autocomplete stays open if you have a custom Popper/Paper so that you can display other information or maybe even a custom "No Items" option.
Context
In our case we have a custom Autocomplete used as a global site search that renders a custom Popper/Paper that includes chips that link to certain "Advanced search" options as well as contains a recently searched section (the Autocomplete's options) that will show recent results. In our current version of MUI v5.10.17 when there are no recent search options the Autocomplete can still be expanded and the Chips used to navigate to advanced search pages.
However, updating to the latest 5.x version of MUI v5.16.7 (bug also present in latest 6.x version) when there are no recent search options and the Autocomplete's options prop is
[]
it will not open, or it will close the Autocomplete if the user has expanded it and options is asynchronously loaded and results in an empty data result. Also when the Autocomplete closes asynchronously because ofoptions=[]
it will not call onClose or update its internalopen
state unless the user does an action that makes it realize it is no longer open (such as clicking somewhere and causing a blur event).This regression was introduced in #41300
Your environment
npx @mui/envinfo
Search keywords: autocomplete freesolo no options custom popper paper
The text was updated successfully, but these errors were encountered: