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-1988): Change time to be read as text #231

Merged
merged 1 commit into from
Jan 6, 2025
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
2 changes: 1 addition & 1 deletion cypress/e2e/transcript.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ describe('Transcript plugin', () => {
keyCode: 9, // tab
force: true
});
cy.get('[aria-label="00:15 listening to music for the first time"]').should('have.focus');
cy.get('[aria-label="Timestamp 15 seconds listening to music for the first time"]').should('have.focus');
});
});

Expand Down
13 changes: 9 additions & 4 deletions src/components/caption/caption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import * as styles from './caption.scss';

import {TranscriptEvents} from '../../events/events';

//@ts-ignore
const {getDurationAsText} = KalturaPlayer.ui.utils
const {withText, Text} = KalturaPlayer.ui.preacti18n;
const {withEventManager} = KalturaPlayer.ui.Event;
const {withPlayer} = KalturaPlayer.ui.components;
Expand All @@ -20,7 +22,8 @@ export interface CaptionProps {
player?: any;
captionLabel?: string;
moveToSearch?: string;
navigationInstruction?: string
navigationInstruction?: string;
timeLabel?: string;
setTextToRead: (textToRead: string, delay?: number) => void;
}

Expand All @@ -39,7 +42,9 @@ interface ExtendedCaptionProps extends CaptionProps {
const translates = {
captionLabel: <Text id="transcript.caption_label">Jump to this point in video</Text>,
moveToSearch: <Text id="transcript.move_to_search">Click to jump to search result</Text>,
navigationInstruction: <Text id="transcript.navigation_instruction">Press Home to navigate to the beginning of the transcript. Press End to jump to the end of the transcript.</Text>
navigationInstruction: <Text id="transcript.navigation_instruction">Press Home to navigate to the beginning of the transcript. Press End to jump to the end of the transcript.</Text>,
timeLabel: <Text id="transcript.time_label">Timestamp</Text>,

};

@withText(translates)
Expand Down Expand Up @@ -145,15 +150,15 @@ export class Caption extends Component<ExtendedCaptionProps> {
};

render() {
const {caption, highlighted, showTime, longerThanHour, indexMap, captionLabel, moveToSearch, navigationInstruction} = this.props;
const {caption, highlighted, showTime, longerThanHour, indexMap, captionLabel, moveToSearch, navigationInstruction, timeLabel, player} = this.props;
const {startTime, id} = caption;
const isHighlighted = Object.keys(highlighted).some(c => c === id);
const time = showTime ? secondsToTime(startTime, longerThanHour) : '';

const captionA11yProps: Record<string, any> = {
ariaCurrent: isHighlighted,
tabIndex: 0,
ariaLabel: `${time}${showTime ? ' ' : ''}${caption.text} ${indexMap ? moveToSearch : captionLabel}. ${navigationInstruction}`,
ariaLabel: `${showTime? `${timeLabel} ${getDurationAsText(Math.floor(startTime), player?.config.ui.locale, true)} ` : ''}${caption.text} ${indexMap ? moveToSearch : captionLabel}. ${navigationInstruction}`,
role: 'button'
};

Expand Down
3 changes: 2 additions & 1 deletion translations/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"move_to_search": "Click to jump to search result",
"to_search_result": "Go to result",
"to_search_result_label": "Click to jump to this point in the video",
"navigation_instruction": "Press Home to navigate to the beginning of the transcript. Press End to jump to the end of the transcript."
"navigation_instruction": "Press Home to navigate to the beginning of the transcript. Press End to jump to the end of the transcript.",
"time_label": "Timestamp"
}
}
}
Loading