Autocomplete defaultvalue for checked options only works if options reference is passed
I created a demo to represent this issue
https://codesandbox.io/s/material-demo-4imuq
In the example, both Autocompletes are able to show the selected values in the input field correctly the issue arises in the second autocomplete when you open the autocomplete you can only see checkbox for the only one value.
Current Behaviour

Expected Behaviour

My apology if i didn't articulate the bug precisely
We document this for the Select component https://material-ui.com/api/select/#props (see value). We need to document it for the Autocomplete component as well.
This is related to #18443. An update of the documentation would be great. Maybe something like this?
diff --git a/packages/material-ui-lab/src/Autocomplete/Autocomplete.js b/packages/material-ui-lab/src/Autocomplete/Autocomplete.js
index 3b1fe0368..99b6ac4f4 100644
--- a/packages/material-ui-lab/src/Autocomplete/Autocomplete.js
+++ b/packages/material-ui-lab/src/Autocomplete/Autocomplete.js
@@ -597,6 +597,9 @@ Autocomplete.propTypes = {
renderTags: PropTypes.func,
/**
* The value of the autocomplete.
+ *
+ * The value must have reference equality with the option in order to be selected.
+ * You can customize the equality behavior with the `getOptionSelected` prop.
*/
value: PropTypes.any,
};
Hey @oliviertassinari !
Can I take this up if no one is working on it?
Sure :)
thanks @eps1lon
is there a way to handle this without passing the reference object ?
@DarkKnight1992 we have two follow-up issues open about this problem. One is about adding a prop to customize the equality check. One is about adding a warning so developers can find this prop. They are good to take, in case you want to push them forward and open pull requests :).
@oliviertassinari would be glad to since i need it one way or another.
I had the same problem i had to hack the renderOption :/

See #18514 and #18443 as two good follow up on this problem.
Most helpful comment
We document this for the Select component https://material-ui.com/api/select/#props (see
value). We need to document it for the Autocomplete component as well.