Skip to content

Commit

Permalink
fix(FEC-14132): fix rendering jump to search result button (#216)
Browse files Browse the repository at this point in the history
* fix(FEC-14132): fix rendering jump to search result button

* fix(FEC-14131): change area label for "go to result" button
  • Loading branch information
semarche-kaltura authored Aug 21, 2024
1 parent ef2a1f1 commit 7fa5f63
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/components/transcript/transcript.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ const translates = {
errorDescripton: <Text id="transcript.load_failed">Failed to load transcript</Text>,
attachTranscript: <Text id="transcript.attach_transcript">Bring Transcript back</Text>,
detachTranscript: <Text id="transcript.detach_transcript">Popout transcript</Text>,
toSearchResult: <Text id="transcript.to_search_result">Go to result</Text>,
toSearchResultLabel: <Text id="transcript.to_search_result_label">Click to jump to this point in the video</Text>
toSearchResult: <Text id="transcript.to_search_result">Go to result</Text>
};

export interface TranscriptProps {
Expand All @@ -57,7 +56,6 @@ export interface TranscriptProps {
attachTranscript?: string;
detachTranscript?: string;
toSearchResult?: string;
toSearchResultLabel?: string;
downloadDisabled: boolean;
onDownload: () => void;
printDisabled: boolean;
Expand Down Expand Up @@ -274,6 +272,24 @@ export class Transcript extends Component<TranscriptProps, TranscriptState> {
return styles.smallWidth;
};

private _renderJumpToSearchButton = () => {
const {toSearchResult, onJumpToSearchMatch} = this.props;
const {search, activeSearchIndex, totalSearchResults} = this.state;
if (!search || totalSearchResults === 0 || activeSearchIndex === 0) {
return null;
}
return (
<Button
type={ButtonType.secondary}
className={styles.toSearchButton}
onClick={onJumpToSearchMatch}
ariaLabel={toSearchResult}
testId="transcript_jumpToSearchMatch">
{toSearchResult}
</Button>
);
};

private _renderHeader = () => {
const {
toggledWithEnter,
Expand All @@ -286,11 +302,8 @@ export class Transcript extends Component<TranscriptProps, TranscriptState> {
isLoading,
attachTranscript,
detachTranscript,
toSearchResult,
toSearchResultLabel,
onAttach,
onDetach,
onJumpToSearchMatch
onDetach
} = this.props;
const {search, activeSearchIndex, totalSearchResults} = this.state;

Expand All @@ -314,16 +327,7 @@ export class Transcript extends Component<TranscriptProps, TranscriptState> {
toggledWithEnter={toggledWithEnter}
kitchenSinkActive={kitchenSinkActive}
/>
{search && activeSearchIndex && (
<Button
type={ButtonType.secondary}
className={styles.toSearchButton}
onClick={onJumpToSearchMatch}
ariaLabel={toSearchResultLabel}
testId="transcript_jumpToSearchMatch">
{toSearchResult}
</Button>
)}
{this._renderJumpToSearchButton()}
<TranscriptMenu {...{downloadDisabled, onDownload, printDisabled, onPrint, isLoading, detachMenuItem, kitchenSinkDetached}} />
{!detachMenuItem && this._renderDetachButton()}
{!kitchenSinkDetached && (
Expand Down

0 comments on commit 7fa5f63

Please sign in to comment.