Description
Currently, HTML <button> elements default to type="submit" when placed inside a <form>. In a large application like Rocket.Chat, using a Fuselage <Button> for actions like "Cancel" or "Close" inside a form context can lead to unintended submissions if the type is not explicitly set.
Proposed Solution
Modify the Button component to default to type="button" while still allowing developers to explicitly override it with type="submit" or type="reset".
Why this matters
This is a defensive programming pattern that prevents subtle UX bugs. By ensuring buttons are "neutral" by default, we improve the reliability of forms across the Rocket.Chat ecosystem.
Changes
- Set default
type = 'button' in the component props.
- Ensure the
type prop is correctly forwarded to the underlying Box or button element.
- Maintain support for
type="submit" when explicitly provided.
I have analyzed the current Button.tsx implementation and submitted a PR with this safer default.