Repository navigation
fix(web): improve accessibility with ARIA labels and keyboard navigation - #180
leoisadev1 wants to merge 2 commits into
Conversation
- Add proper ARIA labels to chat message bubbles indicating sender - Add role='article' to message bubbles for better screen reader context - Enhance model selector with comprehensive ARIA attributes and keyboard loop navigation - Add ARIA labels to combobox trigger, search input, and all options - Improve OpenRouter modal with proper ARIA relationships and focus management - Add aria-describedby for error messages and modal description - Add aria-busy state for submit button during save - Add aria-label to scroll-to-bottom button in chat panel These changes ensure keyboard users and screen reader users can fully interact with the chat interface.
…cements The visible text already includes pricing and context information, so the aria-label should only contain the option label to prevent screen readers from announcing the same information twice.
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
This PR significantly enhances accessibility across three core UI components by adding proper ARIA labels, semantic roles, and improved keyboard navigation.
Key Improvements
- Chat Messages Panel: Added
role="article"and dynamic ARIA labels to message bubbles identifying sender ("Assistant message" or "User message"), plusaria-labelfor scroll-to-bottom button - Model Selector: Implemented circular keyboard navigation via
loopprop, comprehensive ARIA attributes (aria-haspopup="listbox",aria-selected,role="option"), and simplified option labels to prevent duplicate screen reader announcements - OpenRouter Modal: Enhanced form accessibility with
aria-describedbylinking description,aria-required/aria-invalidon input field,role="alert"on error messages, andaria-busyon submit button
Code Quality
All changes follow accessibility best practices and integrate seamlessly with the existing codebase. The components properly spread HTML attributes, ensuring ARIA props are correctly applied. Changes maintain backward compatibility and don't affect visual presentation.
Minor Consideration
One suggestion for the OpenRouter modal's focus management approach - the onOpenAutoFocus handler with e.preventDefault() may interfere with Radix Dialog's built-in keyboard navigation features, though this appears intentional to support the Input's native autoFocus.
Confidence Score: 5/5
- This PR is safe to merge with minimal risk - it only adds accessibility attributes without changing application logic
- Score reflects focused scope (accessibility-only changes), adherence to WCAG standards, no logic modifications, backward compatibility, and proper implementation of ARIA patterns. The single style suggestion about focus management doesn't impact functionality.
- No files require special attention - all changes are straightforward accessibility enhancements
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/web/src/components/chat-messages-panel.tsx | 5/5 | Added ARIA labels and semantic roles to message bubbles and scroll button for screen reader support |
| apps/web/src/components/model-selector.tsx | 5/5 | Enhanced keyboard navigation with loop prop and comprehensive ARIA attributes for model selection listbox |
| apps/web/src/components/openrouter-link-modal.tsx | 4/5 | Improved form accessibility with ARIA relationships, validation states, and focus management |
Sequence Diagram
sequenceDiagram
participant User as Screen Reader User
participant SR as Screen Reader
participant Chat as ChatMessagesPanel
participant Model as ModelSelector
participant Modal as OpenRouterModal
Note over User,Modal: Chat Message Interaction
User->>Chat: Navigate to message
Chat->>SR: Announce "Assistant message" or "User message" (aria-label)
SR->>User: Reads message content with role context
Note over User,Modal: Model Selection Interaction
User->>Model: Focus on model selector button
Model->>SR: Announce "Select AI model. Current selection: [model name]"
User->>Model: Press Enter/Space to open
Model->>SR: Announce expanded state (aria-expanded=true)
User->>Model: Type to search or use arrow keys
Note over Model: Loop prop enables circular navigation
Model->>SR: Announce each option with aria-selected state
User->>Model: Select option with Enter
Model->>SR: Announce new selection
Note over User,Modal: OpenRouter Modal Interaction
User->>Modal: Modal opens
Modal->>SR: Announce dialog title and description (aria-describedby)
Modal->>Modal: Focus moves to API key input
User->>Modal: Enter invalid key
Modal->>SR: Announce error (role="alert", aria-invalid=true)
User->>Modal: Submit form
Modal->>SR: Announce busy state (aria-busy=true)
3 files reviewed, 1 comment
| onOpenAutoFocus={(e) => { | ||
| // Prevent default to allow Input autoFocus to work properly | ||
| e.preventDefault(); | ||
| }} |
There was a problem hiding this comment.
style: Preventing default on onOpenAutoFocus disables Radix Dialog's built-in focus management. While this allows the native autoFocus to work, it may prevent focus trap and keyboard navigation features. Consider removing onOpenAutoFocus entirely since the Input's autoFocus prop should work automatically within the dialog.
|
Closing to recreate with updated branch |
Summary
role="article"attributes for better screen reader contextloopprop to Command component and comprehensive ARIA attributes includingaria-haspopup,aria-label,aria-selected, androle="option"on all interactive elementsaria-describedby), focus management (onOpenAutoFocus), and state indicators (aria-busy,aria-invalid,aria-required)Changes
Chat Messages Panel (
chat-messages-panel.tsx)role="article"to message bubbles for semantic structurearia-labelto scroll-to-bottom buttonModel Selector (
model-selector.tsx)loopprop to Command component for circular keyboard navigationaria-haspopup="listbox"and descriptivearia-labelto trigger buttonrole="listbox"to CommandListrole="option"andaria-selectedto each CommandItemaria-labelto each option (label only, to avoid duplicate announcements)aria-labelto search inputrole="status"to empty stateOpenRouter Link Modal (
openrouter-link-modal.tsx)aria-describedbylinking to modal descriptiononOpenAutoFocushandler for proper focus managementaria-required,aria-invalid, andaria-describedbyto API key inputidto error message for ARIA relationshiprole="alert"to error messagearia-busystate to submit buttonReviewer Feedback Addressed
aria-labelon model selector options to avoid duplicate screen reader announcements (was including pricing/context that's already visually displayed)Testing
Keyboard users can now:
All changes maintain backward compatibility and enhance the user experience for assistive technology users.