Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .Jules/palette.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 2024-05-18 - Screen Reader Compatibility for Loading Spinners
**Learning:** When displaying a loading spinner (like `Loader2` from `lucide-react`) inside a button, screen readers may redundantly or confusingly read out the decorative SVG element if not properly hidden. Additionally, the button itself needs to explicitly declare its busy state.
**Action:** Always add `aria-hidden="true"` to purely decorative loading icons and apply `aria-busy={isLoading}` to the parent `<button>` or interactive element to ensure assistive technologies correctly interpret the state without spamming the user.
3 changes: 2 additions & 1 deletion src/components/ui/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(

const content = showLoader ? (
<>
<Loader2 className="animate-spin" />
<Loader2 className="animate-spin" aria-hidden="true" />
{children}
</>
) : (
Expand All @@ -46,6 +46,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
ref={ref}
disabled={isLoading || props.disabled}
onClick={handleClick}
aria-busy={isLoading}
{...props}
>
{content}
Expand Down
Loading