-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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
[material-ui][Autocomplete] check for previousProps value being not-null after handling option click #42644
[material-ui][Autocomplete] check for previousProps value being not-null after handling option click #42644
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@giulio-opal can you provide sandbox which reproduces error you are describing?
Sorry for the slow turnaround, here's a codesandbox: https://codesandbox.io/p/sandbox/nervous-bush-lzzmfw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably do some weird hack ...
So you shouldn't do this in your app in the first place?
This null check is very hard to patch from our side, and our use of Autocomplete is very similar to the example provided, which should be straightforward. (The "weird hack" was mentioned because I hadn't isolated some additional tweaks that we do for UX purposes on Autocomplete, which then I did in the sandbox) |
But why do you switch from single to multiple autocomplete after user selection? Isn't this bad UX? Autocomplete should either allow single or multiple selections, not both. What's your use case for this? We want to avoid unnecessary code. The |
single -> user is offered some options to drill down to (eg. category) |
I'm unsure about supporting the switch from single to multiple options in Autocomplete upon user selection. Can you add a test case first? I'll ask others to review it. |
Since this PR isn't active, I am closing it. |
We were using an old beta version (@material-ui/lab) of Autocomplete in our codebase and after finally upgrading to v5 we noticed a regression in one of our components based on Autocomplete due to this line checking for
previousProps.value.length
whilepreviousProps.value
wasnull
. I think this is the only place werepreviousProps.value.length
is checked.Context:
We probably do some weird hack in which we switch from a non-multiple to multiple autocomplete dropdown, this is because on first render, we populate the options with a list and then upon user selection, load another list and allow the user to select multiple values out of the dropdown.
Please let me know if there's any test I should be adding/modifying. Thank you!