Skip to content

feat(ui): improve keyboard accessibility for widgets and toolbar#5810

Closed
DhyaniKavya wants to merge 1 commit intosugarlabs:masterfrom
DhyaniKavya:fix/keyboard-accessibility-ui
Closed

feat(ui): improve keyboard accessibility for widgets and toolbar#5810
DhyaniKavya wants to merge 1 commit intosugarlabs:masterfrom
DhyaniKavya:fix/keyboard-accessibility-ui

Conversation

@DhyaniKavya
Copy link
Contributor

issue: #5809

Problem:-
Several interactive UI elements in Music Blocks are not accessible via keyboard navigation.

-Toolbar icons use elements without href, making them non-focusable and unreachable using the Tab key
-Widget buttons are created using

elements with only onclick handlers
-These elements lack role="button" and tabindex="0"
-Keyboard users cannot activate controls using Enter or Space
-Screen readers cannot correctly identify these elements as interactive controls
-This results in violation of WCAG 2.1 (2.1.1 Keyboard, 4.1.2 Name, Role, Value)

While the UI functions correctly with a mouse, it is not accessible to keyboard-only users or assistive technologies.

Solution:-
This PR improves keyboard accessibility while preserving all existing functionality:

-adds role="button" to non-semantic interactive elements
-adds tabindex="0" to enable keyboard focus
-adds keydown handlers to trigger click events on Enter and Space
-does not alter existing click behavior
-does not modify layout or styling

Changes Made:-

-File modified:
-> js/widgets/widgetWindows.js
-> add role="button" to dynamically created widget buttons
-> add tabindex="0" to widget buttons
-> add keydown handler for Enter/Space activation

-File modified:
-> index.html
-> add role="button" to toolbar anchor elements
-> add tabindex="0" to toolbar icons

Testing Performed:-

-Manual Verification
-Toolbar icons reachable via Tab
-Widget buttons focusable using keyboard
-Enter activates controls
-Space activates controls
-Focus order remains logical
-No console errors observed

-Automated Testing

Jest: ✅ all tests passed
Prettier: ✅ formatting verified
ESLint: ⚠️ pre-existing repository configuration warning (no new lint errors introduced)

Impact:-

-Improves keyboard accessibility across the application
-Enables inclusive access for keyboard-only users
-Improves screen reader compatibility
-Enhances WCAG 2.1 compliance
-No breaking changes

Notes:-
This change is intentionally minimal and non-breaking. It enhances accessibility without modifying core logic, UI behavior, or styling. The implementation follows standard accessibility best practices and preserves all existing interactions.

Happy to adjust if maintainers prefer a different approach.

@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@DhyaniKavya
Copy link
Contributor Author

@walterbender @omsuneri Please review these changes if they are useful and if any changes are required i am open to address them . Thankyou

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.

1 participant