-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autocomplete defaultvalue and value for options with checkbox only works if options reference is passed #18499
Comments
We document this for the Select component https://material-ui.com/api/select/#props (see |
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 :) |
…ui#18499-autocomplete-documentation
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. |
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
![image](https://user-images.githubusercontent.com/15063261/69422705-5ef3d300-0d4a-11ea-8a0e-0c7d617bd5d0.png)
Expected Behaviour
![image](https://user-images.githubusercontent.com/15063261/69422727-6e731c00-0d4a-11ea-9154-0e9fba30d312.png)
My apology if i didn't articulate the bug precisely
The text was updated successfully, but these errors were encountered: