You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ToggleSwitch component is based on button tag, but it has no type attribute, so by default it has type="submit". This causes issues when the component is used inside form tag.
Steps to reproduce
Add ToggleSwitch component in form tag.
Make it controllable, add checked and onChange attributes.
Check how many times onChange callback is called on init.
Try to switch toggle
Version
36.27.0
Browser
Chrome
The text was updated successfully, but these errors were encountered:
- Add explicit `type="button"` to SwitchButton to prevent default form submission
- Ensure controlled toggle switch behaves consistently inside form elements
- Resolve issue with multiple onChange calls during initialization
Fixesprimer#5823
I'd like to work on fixing this ToggleSwitch issue. From my initial analysis, the problem stems from the default button type causing unintended form submissions. I'm prepared to submit a PR that adds type="button" to prevent this behavior and ensure consistent component interaction within forms.
Description
ToggleSwitch component is based on
button
tag, but it has notype
attribute, so by default it hastype="submit"
. This causes issues when the component is used insideform
tag.Steps to reproduce
form
tag.checked
andonChange
attributes.onChange
callback is called on init.Version
36.27.0
Browser
Chrome
The text was updated successfully, but these errors were encountered: