Skip to content

fix(ui): keep button text visible during loading states and improve accessibility#71

Open
TeeYml wants to merge 1 commit into
HubDApp:mainfrom
TeeYml:65-button-loading
Open

fix(ui): keep button text visible during loading states and improve accessibility#71
TeeYml wants to merge 1 commit into
HubDApp:mainfrom
TeeYml:65-button-loading

Conversation

@TeeYml

@TeeYml TeeYml commented Jun 19, 2026

Copy link
Copy Markdown

PR Description

Problem
The shared Button component was hiding its children while isLoading was true, only showing a spinner. This caused important context to be lost in several flows (e.g., whether a project was being submitted, updated, or loaded).

Solution
This PR updates the Button component to retain its meaningful text during loading states by default, while still ensuring forms prevent duplicate submits.

Key Changes:

  • Preserved Context: The button's label (children) is no longer hidden when isLoading is true. The spinner now gracefully replaces only the leftIcon.
  • Improved Accessibility:
    • Added aria-busy={isLoading} to communicate the loading state to screen readers.
    • Added aria-hidden="true" to the Loader2 spinner to prevent repetitive or confusing screen reader announcements.
    • Introduced an optional loadingText prop. If a button lacks explicit text or an aria-label, a screen-reader-only (sr-only) fallback text is automatically rendered to ensure strict accessibility compliance.
  • Backwards Compatible: Existing callers will continue to work without layout shifts. Duplicate submissions remain prevented as the disabled={isLoading || disabled} behavior was explicitly retained.

Closes #65

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.

Keep button text visible during loading states

1 participant