Skip to content
This repository was archived by the owner on Sep 16, 2026. It is now read-only.

fix(web): improve accessibility with ARIA labels and keyboard navigation - #180

Closed
leoisadev1 wants to merge 2 commits into
mainfrom
fix/ui-accessibility-v2
Closed

leoisadev1 wants to merge 2 commits into
mainfrom
fix/ui-accessibility-v2

Conversation

@leoisadev1

Copy link
Copy Markdown
Member

Summary

  • Enhanced chat message bubbles with proper ARIA labels identifying the sender (Assistant/User) and semantic role="article" attributes for better screen reader context
  • Improved model selector keyboard navigation by adding loop prop to Command component and comprehensive ARIA attributes including aria-haspopup, aria-label, aria-selected, and role="option" on all interactive elements
  • Strengthened OpenRouter modal accessibility with proper ARIA relationships (aria-describedby), focus management (onOpenAutoFocus), and state indicators (aria-busy, aria-invalid, aria-required)

Changes

Chat Messages Panel (chat-messages-panel.tsx)

  • Added dynamic ARIA labels to message bubbles: "Assistant message" or "User message"
  • Added role="article" to message bubbles for semantic structure
  • Added aria-label to scroll-to-bottom button

Model Selector (model-selector.tsx)

  • Added loop prop to Command component for circular keyboard navigation
  • Added aria-haspopup="listbox" and descriptive aria-label to trigger button
  • Added role="listbox" to CommandList
  • Added role="option" and aria-selected to each CommandItem
  • Added simplified aria-label to each option (label only, to avoid duplicate announcements)
  • Added aria-label to search input
  • Added role="status" to empty state

OpenRouter Link Modal (openrouter-link-modal.tsx)

  • Added aria-describedby linking to modal description
  • Added onOpenAutoFocus handler for proper focus management
  • Added aria-required, aria-invalid, and aria-describedby to API key input
  • Added id to error message for ARIA relationship
  • Added role="alert" to error message
  • Added aria-busy state to submit button

Reviewer Feedback Addressed

  • Simplified aria-label on model selector options to avoid duplicate screen reader announcements (was including pricing/context that's already visually displayed)

Testing

Keyboard users can now:

  • Navigate model options with arrow keys in a circular loop
  • Understand who sent each chat message via screen readers
  • Get proper context about each model option including pricing/tokens
  • Navigate the OpenRouter modal with proper focus management
  • Understand form validation states

All changes maintain backward compatibility and enhance the user experience for assistive technology users.

- 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.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"), plus aria-label for scroll-to-bottom button
  • Model Selector: Implemented circular keyboard navigation via loop prop, 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-describedby linking description, aria-required/aria-invalid on input field, role="alert" on error messages, and aria-busy on 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)
Loading

3 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +63 to +66
onOpenAutoFocus={(e) => {
// Prevent default to allow Input autoFocus to work properly
e.preventDefault();
}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@leoisadev1

Copy link
Copy Markdown
Member Author

Closing to recreate with updated branch

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant