Skip to content

feat(Dock): add keyboard activation and accessible labels#986

Open
Sarthak-Bhagat2006 wants to merge 1 commit into
DavidHDev:mainfrom
Sarthak-Bhagat2006:feat/dock-keyboard-navigation-clean
Open

feat(Dock): add keyboard activation and accessible labels#986
Sarthak-Bhagat2006 wants to merge 1 commit into
DavidHDev:mainfrom
Sarthak-Bhagat2006:feat/dock-keyboard-navigation-clean

Conversation

@Sarthak-Bhagat2006

Copy link
Copy Markdown

Fixes #985 . The Dock component had role="button" and tabIndex={0} on items, making them focusable, but pressing Enter or Space did not trigger the onClick handler — unlike native <button> elements. Items also had no accessible label.

This adds keyboard activation and accessibility semantics:

  • Added onKeyDown handler for Enter and Space to trigger onClick, with preventDefault() on Space to avoid page scroll.
  • Added aria-label to each DockItem, derived from item.label when it's a plain string.

Mouse hover, magnification, and existing click behaviour are unchanged.

Updated across all 4 variants (JS/TS × CSS/Tailwind), per the contributing guidelines.

Note on aria-label

When label is a plain string, it's used as the aria-label. When label is JSX, the item falls back to existing behaviour (no aria-label) — a full fix for JSX labels would need a separate string prop, which felt out of scope here. Happy to add that if preferred.

How it was tested

Check Result
Tab focuses each dock item
Enter activates onClick
Space activates onClick (no page scroll)
Mouse hover/magnification still works
Screen reader announces item label (string labels)

Accessibility

  • Keyboard-only users can now activate dock items
  • Screen readers announce items with string labels via aria-label
  • Follows WAI-ARIA Authoring Practices for the button role

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.

[BUG]: No keyboard navigation support to Dock

1 participant