mirror of
https://github.com/stablyai/orca.git
synced 2026-10-19 00:03:20 +00:00
fix(source-control): make branch identity keyboard accessible
This commit is contained in:
@@ -12,13 +12,15 @@ type DetachedHeadBadgeProps = {
|
||||
label?: 'sidebar' | 'source-control'
|
||||
side?: React.ComponentProps<typeof TooltipContent>['side']
|
||||
className?: string
|
||||
tabIndex?: number
|
||||
}
|
||||
|
||||
export function DetachedHeadBadge({
|
||||
display,
|
||||
label = 'source-control',
|
||||
side = 'right',
|
||||
className
|
||||
className,
|
||||
tabIndex
|
||||
}: DetachedHeadBadgeProps): React.JSX.Element {
|
||||
const visibleLabel = label === 'sidebar' ? display.sidebarLabel : display.sourceControlLabel
|
||||
|
||||
@@ -28,6 +30,7 @@ export function DetachedHeadBadge({
|
||||
<Badge
|
||||
variant="outline"
|
||||
aria-label={display.tooltip}
|
||||
tabIndex={tabIndex}
|
||||
className={cn(
|
||||
'h-[18px] shrink-0 gap-1 rounded px-1.5 text-[10px] font-medium leading-none',
|
||||
'border-[color:color-mix(in_srgb,var(--git-decoration-modified)_30%,transparent)] bg-[color:color-mix(in_srgb,var(--git-decoration-modified)_8%,transparent)] text-[color:var(--git-decoration-modified)]',
|
||||
|
||||
@@ -59,6 +59,7 @@ describe('SourceControlHeaderToolbar', () => {
|
||||
expect(branchIndex).toBeGreaterThan(-1)
|
||||
expect(filterIndex).toBeGreaterThan(branchIndex)
|
||||
expect(markup).toContain('aria-label="Current branch: brennanb2025/source-control-branch-name"')
|
||||
expect(markup).toContain('tabindex="0"')
|
||||
expect(markup).toContain('min-w-0 truncate')
|
||||
})
|
||||
|
||||
@@ -79,6 +80,7 @@ describe('SourceControlHeaderToolbar', () => {
|
||||
expect(markup).toContain(
|
||||
'aria-label="Detached HEAD at 8cec248. You are viewing a commit, not a branch."'
|
||||
)
|
||||
expect(markup).toContain('tabindex="0"')
|
||||
expect(markup).toContain('lucide-git-commit-horizontal')
|
||||
})
|
||||
|
||||
|
||||
@@ -50,7 +50,12 @@ function SourceControlGitIdentityLabel({
|
||||
if (display.kind === 'detached') {
|
||||
return (
|
||||
<span className="flex min-w-0 flex-1 items-center">
|
||||
<DetachedHeadBadge display={display} side="bottom" className="min-w-0 max-w-full shrink" />
|
||||
<DetachedHeadBadge
|
||||
display={display}
|
||||
side="bottom"
|
||||
className="min-w-0 max-w-full shrink"
|
||||
tabIndex={0}
|
||||
/>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
@@ -66,8 +71,9 @@ function SourceControlGitIdentityLabel({
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<span
|
||||
className="flex min-w-0 flex-1 items-center gap-1 font-mono text-xs font-medium leading-none text-foreground/90"
|
||||
className="flex min-w-0 flex-1 items-center gap-1 rounded-sm font-mono text-xs font-medium leading-none text-foreground/90 outline-none focus-visible:ring-1 focus-visible:ring-ring"
|
||||
aria-label={label}
|
||||
tabIndex={0}
|
||||
>
|
||||
<GitBranch className="size-3 shrink-0 text-muted-foreground" aria-hidden="true" />
|
||||
<span className="min-w-0 truncate">{branchName}</span>
|
||||
|
||||
Reference in New Issue
Block a user