-
-
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] Improve autoSelect logic #19270
Comments
@castroCrea I don't understand, could you provide more details? |
I'm sorry for not been clear. For example go on https://material-ui.com/components/autocomplete/#multiple-values the freeSolo one, Me I use it, for email autocompletion, in email form, the user often wrote an email and hit tab to move on. Is that more understandable ? |
👋 Thanks for using Material-UI! We use GitHub issues exclusively as a bug and feature requests tracker, however, For support, please check out https://material-ui.com/getting-started/support/. Thanks! If you have a question on StackOverflow, you are welcome to link to it here, it might help others. |
Thanks for the details. You can implement such logic with the exposed API. |
Do you means by using Ref ? The simpler solution will be to had a keyDown event on Tab like Enter, no ? So i think it's a feature and note really a support ? |
@castroCrea Looking closer, it seems that the auto-select logic is missing a few cases. Thanks for opening this issue.
What do you think of this patch (it would also fix diff --git a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
index a0dcae57a..d0b0fc444 100644
--- a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
+++ b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
@@ -649,7 +649,9 @@ export default function useAutocomplete(props) {
}
if (autoSelect && selectedIndexRef.current !== -1) {
- handleValue(event, filteredOptions[selectedIndexRef.current]);
+ selectNewValue(event, filteredOptions[selectedIndexRef.current]);
+ } else if (autoSelect && freeSolo && inputValue !== '') {
+ selectNewValue(event, inputValue, 'freeSolo');
} else if (!freeSolo) {
resetInputValue(event, value);
} Do you want to work on a pull request? (as well as the corresponding tests) :) |
No Problem, I don't have a lot of time now but I can work on the PR later. I couldn't find any test on autoComplete in the Test Folder. |
@castroCrea Great. If you don't have a lot of time, the most important part would be to confirm that this patch solves your problem, then, maybe a future developer facing the same problem, we take on the task carry it to a stable release. For the test, you can find them in |
@castroCrea if you don't mind I can work on it. |
no I don't mind, actually it will be nice. I don't have time yet. |
@castroCrea could you please tell me which versions of |
I use 4.8.3, the last one |
@castroCrea |
yes exactly |
@castroCrea I just want to make sure I've understand the issue. |
Yes for free solo and multiple |
@oliviertassinari your solution works if |
@SerhiiBilyk We could change the default value of |
Is the fix present in the latest version? The LE: Nevermind, |
For AutoComplete, on Blur when multiple and freeSolo is set.
It will be nice that the value of the input field, validate, like when we hit Enter.
Summary 💡
On multiple and freeSolo, on blur the value in the input is automatically validated
Motivation 🔦
When you have multiple input and one is auto complete, the user expected that when he leave the filed the value is taking care of.
The text was updated successfully, but these errors were encountered: