fix(a11y): improve accessibility for artifacts tree

Add aria-label, aria-expanded attributes and focus-visible styles
for folder buttons. Hide loading skeleton from assistive tech.
This commit is contained in:
yyh
2026-01-26 16:01:22 +08:00
parent 830c286062
commit 765b548be4
2 changed files with 4 additions and 2 deletions

View File

@@ -81,7 +81,7 @@ const ArtifactsSection: FC<ArtifactsSectionProps> = ({ className }) => {
<div className="flex flex-col gap-px">
{isLoading
? (
<div className="px-2.5 py-3">
<div className="px-2.5 py-3" aria-hidden="true">
<div className="h-4 w-full animate-pulse rounded bg-components-panel-bg" />
</div>
)

View File

@@ -45,6 +45,8 @@ const ArtifactsTreeNode: FC<ArtifactsTreeNodeProps> = ({
<div
role={isFolder ? 'button' : undefined}
tabIndex={isFolder ? 0 : undefined}
aria-label={isFolder ? `${node.name} folder` : undefined}
aria-expanded={isFolder ? isExpanded : undefined}
onClick={handleToggle}
onKeyDown={isFolder
? (e) => {
@@ -54,7 +56,7 @@ const ArtifactsTreeNode: FC<ArtifactsTreeNodeProps> = ({
: undefined}
className={cn(
'group flex items-center gap-0 rounded-md py-0.5 pr-1.5',
isFolder && 'cursor-pointer hover:bg-state-base-hover',
isFolder && 'cursor-pointer hover:bg-state-base-hover focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-components-input-border-active',
!isFolder && 'hover:bg-state-base-hover',
)}
style={{ paddingLeft: `${8 + depth * 20}px` }}