-
-
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] Zero (0) integer key display throws #18327
Comments
@OnkelTem Thank you for the bug report. It's an issue with the value What do you think of this diff? Do you want to submit a pull request? :) diff --git a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
index feb69e2f2..e3634d0ce 100644
--- a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
+++ b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
@@ -208,7 +208,7 @@ export default function useAutocomplete(props) {
const open = isOpenControlled ? openProp : openState;
const inputValueFilter =
- !multiple && value && inputValue === getOptionLabel(value) ? '' : inputValue;
+ !multiple && value != null && inputValue === getOptionLabel(value) ? '' : inputValue;
let popupOpen = open; |
@oliviertassinari Working on this. |
@xZliman Should we add a unit test? 🤔 |
@oliviertassinari Yes we can add a unit test to cover that case |
OK cool, I believe we don't test this feature at all, it would be an opportunity to cover it, with this edge case. |
@xZliman Did you make progress? :) |
Hi @oliviertassinari, I didn't find the time to write the tests. |
This particular issue seems to be fixed with the open PR: https://codesandbox.io/s/autocomplete-any-1dmwl
|
An Autocomplete component with a list of integer values with zero, e.g.
[0, 10, 20]
stops displaying proper popup after selecting "0" and displays "No options" instead ifgetOptionLabel
is used, e.g:Please check out this example:
https://codesandbox.io/embed/autocomplete-any-2vfmv
Steps:
Now do the same with the RIGHT control, where the value of ten (10) and not zero (0) is rewritten to "Any". See that this behavior is gone and you can now select any value and get drop-down properly displayed.
The text was updated successfully, but these errors were encountered: