-
-
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] Non-freesolo autocomplete acts like freesolo: passes string to getOptionLabel
instead of option
#36045
Comments
It doesn't look like this bug report has enough info for one of us to reproduce it. Please provide a CodeSandbox (https://mui.com/r/issue-template), a link to a repository on GitHub, or provide a proper minimal code example that reproduces the problem. |
@ZeeshanTamboli I literally did provide enough info. That is no joke. But if you want me to spell it out, here's a minimal example (as you will see, no more information than what was already provided). This tells me you did not bother to try testing what I said would break (assuming I am incorrect that it would break with such a simple example?). export default function App() {
return (
<Autocomplete
options={[{ property: {} }, { property: {} }]}
getOptionLabel={(opt) => opt.property.subProperty} // <-- this is the only line that matters; literally exactly the same as what I already said.
renderInput={(params) => <TextField {...params} />}
/>
);
} |
@HansBrende Only explaining it in full sentences is not enough information for us. You could be explaining something else, while the reproduction code could yield different results. Anyway, here's a CodeSandbox reproduction: https://codesandbox.io/s/angry-tree-2jcp3o?file=/src/App.tsx. Thanks for your code example. |
getOptionLabel
instead of optiongetOptionLabel
instead of option
@ZeeshanTamboli I provided, not only "full sentences", but the exact code for |
@HansBrende What is your use case for having multiple (in your case, two-level) nested options? Do you somehow use it in the |
const options = [{isEmpty: true}, {isEmpty: false, data: {}}];
const getOptionLabel = opt => opt.isEmpty ? 'NO DATA' : opt.data.subProperty; No, my code does not have room for improvement, and I'm certainly not going to rewrite my code to accommodate your regression; I'm going to pin mui/material to the previous patch version until this is fixed. |
Looking at the code, the This shouldn't be the case. The Because of that, the |
I created #36088 PR - it will maintain the Thanks to that, it will neither break the contract nor the internals. |
Includes needed fix for mui/material-ui#36045
Includes needed fix for mui/material-ui#36045
Duplicates
Latest version
Steps to reproduce 🕹
Steps:
getOptionLabel
as(opt) => opt.property.subProperty
(for some "property" field)CodeSandbox: https://codesandbox.io/s/angry-tree-2jcp3o?file=/src/App.tsx
I'm assuming that's because I'm being passed a string instead of an object of the expected type. However I was trying to debug this in prod with an upset user so I did not have time to check for sure.
This bug ONLY occurs on v5.11.7. When I pinned @mui/material to v5.11.6, the behavior went away, and user reported no further issues. I'm assuming this is the result of your recent changes to freesoloing autocompletes in the release from 3 days ago.
Current behavior 😯
No response
Expected behavior 🤔
No response
Context 🔦
No response
Your environment 🌎
No response
The text was updated successfully, but these errors were encountered: