-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Open
Labels
docsImprovements or additions to the documentation.Improvements or additions to the documentation.scope: autocompleteChanges related to the autocomplete. This includes ComboBox.Changes related to the autocomplete. This includes ComboBox.
Description
Current behavior 😯
When using different types for options and value properties, the getOptionLabel method is passed value instead of option object.
let's say I'm using following types:
type Option = { label: string; value: any; group?: string }
type Value = string;I'm expecting getOptionLabel method always passed an Option type but that's not the case. That's why the picked option can not be displayed properly.
getOptionLabel={(option) => option.label || "!!!"} //here sometimes Value type is passes instead of Option type.
isOptionEqualToValue={(option, value) => return option.value === value}Expected behavior 🤔
Always pass and option to getOptionLabel as a param to be consistent.
Steps to reproduce 🕹
Here's a demo:
https://codesandbox.io/s/controllablestates-material-demo-forked-0lekyg?file=/demo.js
Steps:
- Render a controlled Autocomplete component using different types for
optionsandvalueprops. (object and string) - Utilize
isOptionEqualToValueandgetOptionLabelcallback props
Context 🔦
I'm trying to render options that are objects like {label:"Label", value:"some value"}, but I want to use the value of the selected option instead of the whole option object.
Your environment 🌎
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
docsImprovements or additions to the documentation.Improvements or additions to the documentation.scope: autocompleteChanges related to the autocomplete. This includes ComboBox.Changes related to the autocomplete. This includes ComboBox.