-
-
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
[Autocomplete] Prevent form submit with freeSolo and multiple #18958
Labels
bug 🐛
Something doesn't work
component: autocomplete
This is the name of the generic UI component, not the React module!
good first issue
Great for first contributions. Enable to learn the contribution process.
Comments
oliviertassinari
added
component: autocomplete
This is the name of the generic UI component, not the React module!
bug 🐛
Something doesn't work
good first issue
Great for first contributions. Enable to learn the contribution process.
labels
Dec 25, 2019
You can enable "required" tag in your textfield. |
I think that this is a leftover during the initial implementation. I would propose the following diff: diff --git a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
index 7a799b1b81..8baf322864 100644
--- a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
+++ b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
@@ -586,6 +586,10 @@ export default function useAutocomplete(props) {
);
}
} else if (freeSolo && inputValueFilter !== '') {
+ if (multiple) {
+ // Allow people to add new values before they submit the form.
+ event.preventDefault();
+ }
selectNewValue(event, inputValue);
}
break; Does somebody want to work on a pull request? :) |
oliviertassinari
changed the title
[Autocomplete] Should input prevent form submit by default when use freeSolo and multiple mode?
[Autocomplete] Prevent form submit with freeSolo and multiple
Dec 27, 2019
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Hi I would like to give this a go and also this will be my first contribution ever |
@haseebdaone You are good to go :) |
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug 🐛
Something doesn't work
component: autocomplete
This is the name of the generic UI component, not the React module!
good first issue
Great for first contributions. Enable to learn the contribution process.
https://codesandbox.io/s/vibrant-water-pepu1
The text was updated successfully, but these errors were encountered: