Skip to content

Commit 0da5381

Browse files
authored
🤖 feat: add aria-labels to ProjectSidebar and fix path text cutoff (#524)
Added aria-labels to ProjectSidebar components for better screen reader support and fixed vertical text clipping in path displays. ## Changes **Accessibility improvements:** - Added `aria-label` to project expand/collapse buttons - Added `role="region"` with descriptive labels to workspace list containers - Added `aria-label` to workspace selection buttons - Added `aria-label` to sidebar collapse/expand button **Text rendering fix:** Changed `leading-none` to `leading-tight` in path displays (both drag preview and sidebar). The `leading-none` style set line-height to 1, which caused vertical text clipping with certain characters, particularly those with descenders or accents. _Generated with `cmux`_
1 parent 8b9fcd5 commit 0da5381

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

‎src/components/ProjectSidebar.tsx‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type DraggableProjectItemProps = React.PropsWithChildren<{
3737
tabIndex?: number;
3838
"aria-expanded"?: boolean;
3939
"aria-controls"?: string;
40+
"aria-label"?: string;
4041
"data-project-path"?: string;
4142
}>;
4243

@@ -140,7 +141,7 @@ const ProjectDragLayer: React.FC = () => {
140141
<span className="text-dim mr-1.5 text-xs">â ¿</span>
141142
<span className="text-muted mr-2 text-xs">â–¶</span>
142143
<div className="min-w-0 flex-1">
143-
<div className="text-muted-dark font-monospace truncate text-sm leading-none">
144+
<div className="text-muted-dark font-monospace truncate text-sm leading-tight">
144145
<span>{dirPath}</span>
145146
<span className="text-foreground font-medium">{basename}</span>
146147
</div>
@@ -475,6 +476,7 @@ const ProjectSidebarInner: React.FC<ProjectSidebarProps> = ({
475476
tabIndex={0}
476477
aria-expanded={isExpanded}
477478
aria-controls={workspaceListId}
479+
aria-label={`${isExpanded ? "Collapse" : "Expand"} project ${projectName}`}
478480
data-project-path={projectPath}
479481
>
480482
<span
@@ -494,7 +496,7 @@ const ProjectSidebarInner: React.FC<ProjectSidebarProps> = ({
494496
</span>
495497
<div className="flex min-w-0 flex-1 items-center pr-2">
496498
<TooltipWrapper inline>
497-
<div className="text-muted-dark font-monospace truncate text-sm leading-none">
499+
<div className="text-muted-dark font-monospace truncate text-sm leading-tight">
498500
{(() => {
499501
const abbrevPath = abbreviatePath(projectPath);
500502
const { dirPath, basename } = splitAbbreviatedPath(abbrevPath);
@@ -549,7 +551,11 @@ const ProjectSidebarInner: React.FC<ProjectSidebarProps> = ({
549551
</DraggableProjectItem>
550552

551553
{isExpanded && (
552-
<div id={workspaceListId}>
554+
<div
555+
id={workspaceListId}
556+
role="region"
557+
aria-label={`Workspaces for ${projectName}`}
558+
>
553559
<div className="border-hover border-b px-3 py-2 pl-[22px]">
554560
<button
555561
onClick={() => onAddWorkspace(projectPath)}
@@ -635,6 +641,7 @@ const ProjectSidebarInner: React.FC<ProjectSidebarProps> = ({
635641
<TooltipWrapper inline>
636642
<button
637643
onClick={onToggleCollapsed}
644+
aria-label={collapsed ? "Expand sidebar" : "Collapse sidebar"}
638645
className="text-muted border-dark hover:bg-hover hover:text-foreground mt-auto flex h-9 w-full cursor-pointer items-center justify-center border-t border-none bg-transparent p-0 text-sm transition-all duration-200"
639646
>
640647
{collapsed ? "»" : "«"}

‎src/components/WorkspaceListItem.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ const WorkspaceListItemInner: React.FC<WorkspaceListItemProps> = ({
124124
role="button"
125125
tabIndex={0}
126126
aria-current={isSelected ? "true" : undefined}
127+
aria-label={`Select workspace ${displayName}`}
127128
data-workspace-path={namedWorkspacePath}
128129
data-workspace-id={workspaceId}
129130
>

0 commit comments

Comments
 (0)