Accessibility Issue: AsciinemaPlayer component accessibility improvements
WCAG Level: A
Severity: Low
Category: Media Accessibility / Dynamic Content
Issue Description
The AsciinemaPlayer component embeds terminal recordings but may lack proper accessibility features for screen reader users and keyboard navigation. The component creates a div that holds the player but doesn't provide:
- An accessible label for the player container
- Fallback content for users who cannot view the recording
- Keyboard instructions for controlling playback
User Impact
- Affected Users: Screen reader users, keyboard-only users, users who cannot view animations
- Severity: Users may not understand the content of terminal recordings
Violations Found
File: src/components/AsciinemaPlayer/AsciinemaPlayer.tsx
Lines: 38-44
return (
<BrowserOnly>
{
() => {
// ...
return <div ref={ref} style={style} />;
}
}
</BrowserOnly>
)
Issue:
- The player container div has no accessible label
- No fallback content when player is unavailable
- No description of what the recording demonstrates
Recommended Fix
type AsciinemaPlayerProps = {
src: string;
style: React.CSSProperties;
title?: string; // Add accessible title
description?: string; // Add accessible description
// ... other props
};
const AsciinemaPlayer: React.FC<AsciinemaPlayerProps> = ({
src,
style,
title,
description,
...asciinemaOptions
}) => {
return (
<BrowserOnly
fallback={
<div role="img" aria-label={title || "Terminal recording"}>
<p>{description || "Terminal recording - content available in browser"}</p>
</div>
}
>
{
() => {
if (!ExecutionEnvironment.canUseDOM) {
return (
<div role="img" aria-label={title || "Terminal recording"}>
ASCII Cinema Player Unavailable
</div>
);
}
const AsciinemaPlayerLibrary = require('asciinema-player');
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
const currentRef = ref.current;
AsciinemaPlayerLibrary.create(src, currentRef, asciinemaOptions);
}, [src]);
return (
<div
ref={ref}
style={style}
role="img"
aria-label={title || "Terminal recording"}
aria-describedby={description ? `${src}-desc` : undefined}
>
{description && (
<span id={`${src}-desc`} className="visually-hidden">
{description}
</span>
)}
</div>
);
}
}
</BrowserOnly>
)
};
Changes Made:
- Added
title and description props for accessibility
- Added
role="img" and aria-label to the container
- Improved fallback content for SSR/no-JS scenarios
- Added
aria-describedby for longer descriptions
Usage Example
<AsciinemaPlayer
src="/casts/example.cast"
title="Installing shell samples"
description="This recording demonstrates how to download and extract the effective shell samples using curl and tar commands."
style={{ width: '100%' }}
/>
Testing Instructions
- Enable a screen reader
- Navigate to a page with an AsciinemaPlayer component
- Verify the screen reader announces the title/purpose of the recording
- Test keyboard navigation within the player
- Disable JavaScript and verify fallback content appears
Resources
Acceptance Criteria
Accessibility Issue: AsciinemaPlayer component accessibility improvements
WCAG Level: A
Severity: Low
Category: Media Accessibility / Dynamic Content
Issue Description
The AsciinemaPlayer component embeds terminal recordings but may lack proper accessibility features for screen reader users and keyboard navigation. The component creates a div that holds the player but doesn't provide:
User Impact
Violations Found
File:
src/components/AsciinemaPlayer/AsciinemaPlayer.tsxLines: 38-44
Issue:
Recommended Fix
Changes Made:
titleanddescriptionprops for accessibilityrole="img"andaria-labelto the containeraria-describedbyfor longer descriptionsUsage Example
Testing Instructions
Resources
Acceptance Criteria