Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ADA-16): Transcript search results inaccessible to screen reader #164

Merged
merged 3 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions cypress/e2e/transcript.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,23 @@ describe('Transcript plugin', () => {
});
});
});

it('should move focus to current caption in search results', () => {
mockKalturaBe();
loadPlayer().then((kalturaPlayer) => {
cy.get('[data-testid="transcript_header"] [aria-label="Search in Transcript"]').get('input').type('music').then(()=> {
kalturaPlayer.currentTime = 20;
kalturaPlayer.pause();
cy.get('[data-testid="transcript_skipButton"]').focus();
cy.wait(300);
cy.get('[data-testid="transcript_skipButton"]').trigger('keydown', {
keyCode: 9, // tab
force: true
});
cy.get('[aria-label="00:15 listening to music for the first time"]').should('have.focus');
});
});
});
});

describe('popover menu', () => {
Expand Down
12 changes: 11 additions & 1 deletion src/components/caption-list/captionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export class CaptionList extends Component<Props> {
shouldScroll: this._getShouldScroll(id),
shouldScrollToSearchMatch: this._getShouldScrollToSearchMatch(id),
isAutoScrollEnabled,
searchCaption: this.props.searchMap[captionData.id],
...this._getSearchProps(id)
};
return newCaptionProps;
Expand All @@ -104,6 +105,7 @@ export class CaptionList extends Component<Props> {

render() {
const {data} = this.props;
let isSearchCaption = false;
Tzipi-kaltura marked this conversation as resolved.
Show resolved Hide resolved
return (
<div className={styles.transcriptWrapper} onKeyUp={this._handleKeyUp} aria-live="polite">
{data.map((captionData, index) => {
Expand All @@ -116,7 +118,15 @@ export class CaptionList extends Component<Props> {
} else if (index === data.length - 1) {
this._lastCaptionRef = node;
}
if (captionProps.highlighted[captionData.id]) {
if (captionProps.searchCaption){
Object.keys(captionProps.searchCaption).forEach(key => {
if (parseInt(key) === this.props.activeSearchIndex) {
this._currentCaptionRef = node
isSearchCaption = true;
}
});
}
if (!isSearchCaption && captionProps.highlighted[captionData.id]) {
this._currentCaptionRef = node;
}
}}
Expand Down
1 change: 1 addition & 0 deletions src/components/transcript/transcript.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export class Transcript extends Component<TranscriptProps, TranscriptState> {
ref={node => {
this._skipTranscriptButtonRef = node;
}}
data-testid="transcript_skipButton"
className={styles.skipTranscriptButton}
onKeyDown={this._handleKeyDown}
onClick={this._handleClick}
Expand Down