Skip to content

Conversation

@Kalpana-chavhan
Copy link

@Kalpana-chavhan Kalpana-chavhan commented Jan 2, 2026

What this PR does

This PR addresses two areas of improvement for the Button component:

  1. Accessibility: Adds a development-time warning when a Button is icon-only, loading, or square but lacks an aria-label or aria-labelledby.
  2. Form Safety: Sets type="button" as the default attribute. In HTML, buttons inside forms default to type="submit", which often leads to unintended form submissions when developers use buttons for actions like "Cancel" or "Close".

Why this is needed

  • A11y: Screen readers cannot identify the purpose of icon-only buttons without an accessible name.
  • UX: Prevents accidental page reloads and form submissions, aligning Fuselage with modern UI library standards (MUI, Radix).

Changes

  • Destructured type with a default of 'button'.
  • Implemented Children.toArray check for accessible text content.
  • Added process.env.NODE_ENV check for console warnings.

Testing

  • Tested <Button icon="edit" /> triggers a warning.
  • Tested <Button type="submit">Submit</Button> still renders correctly as a submit button.

closes #1813

@changeset-bot
Copy link

changeset-bot bot commented Jan 2, 2026

⚠️ No Changeset found

Latest commit: d4cc450

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(fuselage): ensure Button defaults to type="button" to prevent accidental form submissions Body:

1 participant