-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
[Button] Fix running formAction when passed #47185
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
base: master
Are you sure you want to change the base?
Conversation
Netlify deploy previewhttps://deploy-preview-47185--material-ui.netlify.app/ Bundle size report
|
| if (ComponentProp === 'button') { | ||
| buttonProps.type = type === undefined ? 'button' : type; | ||
| // Don't default to 'button' if form attributes are present, to allow form submission | ||
| const hasFormAttributes = !!other.formAction; |
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.
ButtonBase was defaulting to type="button" when no type prop was provided, which prevented form submission and broke formAction functionality. The fix checks for form-related attributes and skips the default type to allow the browser's natural submit behavior (type="submit").
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.
ButtonBase was defaulting to type="button" when no type prop was provided, which prevented form submission and broke formAction functionality
I think this is worth added as a comment in the code because ButtonBase is a child of the Button
siriwatknp
left a comment
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.
👍
minor comment.
closes #47181
Before
https://codesandbox.io/p/sandbox/pedantic-germain-nc325h?file=%2Fsrc%2FApp.tsx%3A1%2C1-24%2C1
After
https://stackblitz.com/edit/8rfko5fh?file=src%2FDemo.tsx