Repository navigation
Implement WCAG 2.1 AA accessible focus trap and ARIA attributes in Notification Center - #1619
Merged
Conversation
Introduces useFocusTrap hook and enhances NotificationCenter component to meet WCAG 2.1 AA accessibility standards: Focus Trap Implementation: - Custom useFocusTrap hook with Tab/Shift+Tab cycling - Escape key support for keyboard trap compliance (WCAG 2.1.2) - Automatic focus management on open/close - Returns focus to trigger button when panel closes - Filters disabled and hidden elements from tab order NotificationCenter ARIA Enhancements: - Added close button in panel header for better discoverability - Enhanced aria-label with aria-describedby for screen readers - Added explicit tabIndex to dismiss buttons - Improved focus-visible styles (WCAG 2.4.7) - Increased touch target sizes to 44x44px (WCAG 2.5.5) - Added sr-only description for assistive technology Keyboard Navigation: - Escape key closes panel and returns focus - Tab/Shift+Tab cycles through focusable elements - No keyboard trap - users can always exit with Escape Part of emdevelopa#1497.
Adds complete test coverage for WCAG 2.1 AA focus trap functionality: Tests Cover: - Initial focus management (first element focused on enable) - Tab key navigation (forward cycling) - Shift+Tab navigation (backward cycling) - Escape key handling for keyboard trap compliance - Focus return on deactivation - Disabled state behavior - Disabled element filtering from tab order - Empty container edge case handling WCAG Compliance Validation: - 2.4.3 Focus Order: Tab navigation follows logical sequence - 2.1.2 No Keyboard Trap: Escape key always available - 2.4.7 Focus Visible: Focus management is predictable - Ensures assistive technology compatibility All tests verify that users can always exit the focus trap and that keyboard navigation follows a predictable, accessible pattern. Closes emdevelopa#1497.
|
@springswell Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
@springswell is attempting to deploy a commit to the Emmanuel's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements WCAG 2.1 AA compliant focus trap and enhances ARIA attributes in the Notification Center component, significantly improving accessibility for keyboard users and assistive technology.
Key Improvements:
Implementation Details
1. Custom Focus Trap Hook:
useFocusTrapCreated a reusable, framework-agnostic focus trap hook that implements:
Focus Management:
Keyboard Navigation:
Focusable Element Detection:
tabindexattributes2. NotificationCenter ARIA Enhancements
New ARIA Attributes:
aria-describedby: Links panel to screen reader descriptionaria-labelon close and dismiss buttonsrole="dialog"witharia-modal="true"for proper modal semanticsidreferences for better screen reader navigationStructural Improvements:
sr-onlyclass)Touch Target Compliance (WCAG 2.5.5):
3. Keyboard Navigation Flow
Opening the Panel:
role="dialog"andaria-modal="true"Navigating the Panel:
Closing the Panel:
4. WCAG 2.1 AA Compliance
This implementation specifically addresses:
2.1.2 No Keyboard Trap:
2.4.3 Focus Order:
2.4.7 Focus Visible:
ring-[#00F5D4]/60)2.5.5 Target Size:
4.1.3 Status Messages:
aria-live="polite"on unread countrole="status"on empty state messageTesting
Unit Tests (useFocusTrap.test.ts)
Comprehensive test coverage includes:
Manual Testing Checklist
Keyboard Navigation:
Screen Reader Testing:
Touch/Mobile Testing:
Cross-Browser:
Accessibility Audit Results
Before this PR:
After this PR:
Browser Compatibility
Uses standard DOM APIs:
KeyboardEvent(widely supported)querySelector/querySelectorAll(universal)focus()method (standard)Breaking Changes
None. This is a purely additive enhancement that:
Future Enhancements
Potential follow-ups (not in scope for this PR):
Closes #1497
Closes #1492
Closes #1495
Closes #1496