-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[Select] Provide prop to allow custom option equality comparison #24201
Comments
This is similar to #17764. Based on the fact that we could get away from this issue without a lot of user request would suggest we don't need to do anything about it. In the Autocomplete component, the prop
We also recommend providing a serializable string |
I have added the |
I feel like it's pretty common use-case to populate options of select input with response from one endpoint and then provide initial value that you got from other endpoint. In case you are using |
I'm facing the same situation, when editing and the input is an object and, from here, "If the value is an object it must have reference equality with the option in order to be selected", if there is a separate array with options, the objects will not be eq. so it can be a feature :) using object.id as value/key works good |
What exactly is the blocker from just adding a |
Summary 💡
I'm facing an issue where I'm getting the
You have provided an out-of-range value
warning in theSelect
component because my objects are failing the comparison check. This is because my initial value is not an object from the available options list, but an object I retrieved from the server with which I'm initializing my form. However all the properties are the same (namelyid
) so it should still recognize that this is the same object.Examples 🌈
https://github.com/mui-org/material-ui/blob/master/packages/material-ui/src/Select/SelectInput.js#L14
I propose making
areEqualValues
the default value for an optional prop on theSelectInput
component, which can be overridden by a custom validation function.I'd like to do
Motivation 🔦
Even though my objects fail the equality check, they're still representing the same database entity, so I should be able to customize the validation myself.
The text was updated successfully, but these errors were encountered: