mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
93.96k stars 32.27k forks source link

[Autocomplete] Warn when value and option doesn't match #18514

Closed guimex22 closed 4 years ago

guimex22 commented 4 years ago

Hi, I am trying to change list options and default value from state. List option is ok but default value is never update.

I have add an exemple on this code box : https://codesandbox.io/s/test-material-ui-autocomplete-700nh?fontsize=14&hidenavigation=1&theme=dark

Thank you for yours ideas...

NoelBq commented 1 year ago
  options={[value, ...serverOptions]} // Currently selected value must be preset to not trigger the missing value warning.
  filterOptions={() => serverOptions} // But we only show what BE returned to us, so there are no duplicates.
  value={value}

this worked for me. I had a reset button and it was virtually impossible to reset the autocomplete without getting that hideous warning. Thanks so much ✨