From 640a8836b6bb3ca4a7adeda41662777b5a60ffcc Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 17 Jan 2026 22:31:23 +0000 Subject: [PATCH] Improve accessibility across components FileTree: - Add ARIA labels to new file button - Add role="button", tabIndex, and keyboard navigation (Enter/Space) for file/folder items - Add aria-label for expand/collapse folder states - Add aria-expanded attribute for folders - Add focus ring styles (focus:ring-2 focus:ring-accent) - Add aria-hidden to decorative icons SearchInFilesPanel: - Add ARIA labels to close button and search button - Add aria-label to search input - Add aria-live="polite" to results count badge - Add keyboard navigation (Enter/Space) to search results - Add focus ring styles to search results - Add role="button" to clickable result items - Add aria-label to case sensitive checkbox - Add aria-hidden to decorative icons AIChat: - Add aria-live="polite" to chat messages area - Add role="log" to messages container - Add aria-label to message input textarea - Add aria-label to send button - Add role="note" to keyboard shortcut hint - Add aria-hidden to decorative icons --- src/components/AIChat.tsx | 14 ++++++++------ src/components/FileTree.tsx | 19 +++++++++++++++++-- src/components/SearchInFilesPanel.tsx | 27 +++++++++++++++++++-------- 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/src/components/AIChat.tsx b/src/components/AIChat.tsx index 5c59965..cada2d1 100644 --- a/src/components/AIChat.tsx +++ b/src/components/AIChat.tsx @@ -73,12 +73,12 @@ export function AIChat({ currentCode }: AIChatProps) { return (
- +
- -
+ +
{messages.map((message, index) => (
-

+

Press Enter to send, Shift+Enter for new line

diff --git a/src/components/FileTree.tsx b/src/components/FileTree.tsx index 3627a6f..2d96d8f 100644 --- a/src/components/FileTree.tsx +++ b/src/components/FileTree.tsx @@ -147,13 +147,27 @@ export function FileTree({ return (
handleDragStart(e, node)} onDragOver={(e) => handleDragOver(e, node)} onDragLeave={handleDragLeave} onDrop={(e) => handleDrop(e, node)} onDragEnd={handleDragEnd} - className={`flex items-center gap-1 px-2 py-1.5 md:py-1 hover:bg-muted/60 cursor-pointer group rounded-sm transition-colors touch-manipulation ${ + onKeyDown={(e) => { + if (e.key === 'Enter' || e.key === ' ') { + e.preventDefault(); + if (node.type === 'folder') { + toggleFolder(node.id); + } else { + onFileSelect(node); + } + } + }} + className={`flex items-center gap-1 px-2 py-1.5 md:py-1 hover:bg-muted/60 cursor-pointer group rounded-sm transition-colors touch-manipulation focus:outline-none focus:ring-2 focus:ring-accent focus:ring-offset-1 ${ isSelected ? 'bg-accent/30 text-accent font-semibold' : 'text-foreground' } ${isDragging ? 'opacity-50' : ''} ${isDropTarget && node.type === 'folder' ? 'bg-blue-500/20 border-2 border-blue-500 border-dashed' : ''}`} style={{ paddingLeft: `${depth * 10 + 8}px` }} @@ -234,6 +248,7 @@ export function FileTree({ size="icon" className="h-6 w-6" title="New File" + aria-label="Create new file" onClick={() => { const name = prompt('Enter file name:'); if (name) { @@ -241,7 +256,7 @@ export function FileTree({ } }} > - +
diff --git a/src/components/SearchInFilesPanel.tsx b/src/components/SearchInFilesPanel.tsx index 6558aac..c1244bb 100644 --- a/src/components/SearchInFilesPanel.tsx +++ b/src/components/SearchInFilesPanel.tsx @@ -119,16 +119,16 @@ export function SearchInFilesPanel({
- +
-
@@ -142,9 +142,10 @@ export function SearchInFilesPanel({ if (e.key === 'Enter') handleSearch(); }} className="flex-1" + aria-label="Search query" /> -
@@ -156,6 +157,7 @@ export function SearchInFilesPanel({ checked={caseSensitive} onChange={(e) => setCaseSensitive(e.target.checked)} className="rounded" + aria-label="Case sensitive search" /> Case sensitive @@ -179,8 +181,17 @@ export function SearchInFilesPanel({ {results.map((result, index) => (
handleResultClick(result)} - className="p-2 rounded hover:bg-muted/60 cursor-pointer group transition-colors border border-transparent hover:border-accent/30" + onKeyDown={(e) => { + if (e.key === 'Enter' || e.key === ' ') { + e.preventDefault(); + handleResultClick(result); + } + }} + aria-label={`Open ${result.fileName} at line ${result.line}`} + className="p-2 rounded hover:bg-muted/60 cursor-pointer group transition-colors border border-transparent hover:border-accent/30 focus:outline-none focus:ring-2 focus:ring-accent focus:ring-offset-1" >