-
-
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
[Autocomplete] Mistake in error message #19163
Comments
Ah, great catch! There is a small error in the warning message. Feel free to submit a pull request to fix it :). diff --git a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
index de0bfd292..f3ba2747b 100644
--- a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
+++ b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
@@ -216,7 +216,7 @@ export default function useAutocomplete(props) {
`The component expect a string but received ${typeof optionLabel}.`,
`For the input option: ${JSON.stringify(
newValue,
- )}, \`getOptionLabel\` returns: ${newInputValue}.`,
+ )}, \`getOptionLabel\` returns: ${optionLabel}.`,
].join('\n'),
);
} |
Can you explain me why it doesn't put the tag with my selected value also btw ? |
I don't understand your problem. It's seems to be a feature request we have no plan to support. |
Well my question is why when i have a multiple autocomplete. And i put 2 elements in the list for example. They are already selected in the field. But when we don't have the property multiple and we have only one element. It doesn't select the element passed in the value. |
OK, then, the warning is here to help. Otherwise, you can ask for the solution on StackOverflow. |
Current Behavior 😯
Hi i'm Florian,
i've encountered a problem with the Autocomplete component that you can see here :
<Autocomplete id="conducteur" renderInput={ (params:RenderInputParams) => ( <TextField {...params} variant="standard" label="Veuillez choisir le conducteur" fullWidth /> )} renderOption={ (option: Person) => (<Typography noWrap>{
${option.prenom} ${option.nom}}</Typography>) } options={persons} value={data.conducteur} onChange={(event: object,person: Person) => { setData( oldState => { oldState?.conducteur = person return oldState }) } } getOptionSelected={(option, value) => option.id === value.id } renderTags={(value: Person[], getTagProps) => value.map((option: Person, index: number) => ( <Chip variant="outlined" key={index} label={
${option.prenom} ${option.nom}} {...getTagProps({ index })} /> ))} />
So i've put something in renderOptions but on my web browser i found this error :
but i checked the source code and getOptionLabel shouldn't be called if renderOption is fill.
Interesting or not when i put the property multiple it works fine but without it doesn't work.
Expected Behavior 🤔
The expected Behavior should be no error if renderOption is fill in the case of a standard autocomplete without multiple property and with renderOption filled.
Steps to Reproduce 🕹
I've done a codeSandBox to reproduce the problem simply :
https://codesandbox.io/s/tender-gates-13t51
Context 🔦
I'm trying to select a person into a list of person which his the driver of a car in my app.
i'm ont the latest version of material ui and lab.
if you need more details please tell me i'll will be please to help you.
Thank you guys for taking the time to read this.
The text was updated successfully, but these errors were encountered: