Skip to content

[Select] Provide prop to allow custom option equality comparison #24201

Closed
@brno32

Description

@brno32
  • I have searched the issues of this repository and believe that this is not a duplicate.

Summary 💡

I'm facing an issue where I'm getting the You have provided an out-of-range value warning in the Select 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 (namely id) 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 the SelectInput component, which can be overridden by a custom validation function.

I'd like to do

<Select validateOption={(a, b) => a.id === b.id} />

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: selectThis is the name of the generic UI component, not the React module!waiting for 👍Waiting for upvotes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions