Autocomplete clear button acting as type="submit" by default #39262
Labels
bug 🐛
Something doesn't work
component: autocomplete
This is the name of the generic UI component, not the React module!
package: base-ui
Specific to @mui/base
package: joy-ui
Specific to @mui/joy
Steps to reproduce 🕹
Hi, thanks for the great library, and sorry if this has been reported elsewhere.
Link to live example:
Here is a basic HTML repro that illustrates the problem:
Steps :
Current behavior 😯
I've found what I think is a little usability issue and something that is probably very easy to change. Basically the clear button in a MUI-joy auto-complete field doesn't have the type attribute which means it defaults to type="submit".
This can result in the form getting submitted when the clear button is clicked or when the user hits the enter key in another field, if the field resides in a form tag.
Expected behavior 🤔
I think a clear button should never have the capability of submitting the form on behalf of the user as the clear button is explicitly for clearing the autocomplete field only, so my hope is you could add the
type="button"
attribute to the clear buttonContext 🔦
I have my form fields wrapped in a form tag because 1) it's semantically correct, 2) I want to use native form validation which is very useful for mobile and reducing the number of translations needed (and I need to trigger it manually at a certain point).
The clear button being present as a submit button by default, tells the browser that the enter key should be able to trigger a form submit before I'm ready for them to submit.
Your environment 🌎
No response
The text was updated successfully, but these errors were encountered: