Skip to content

Commit

Permalink
fix(ADA-1335): Accessibility- “Close” button within the info video pa…
Browse files Browse the repository at this point in the history
…nel.
  • Loading branch information
Tzipi-kaltura committed Jun 30, 2024
1 parent 6a60198 commit 982f812
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/components/info/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface ConnectProps {
interface KeyboardA11yProps {
handleKeyDown?: () => void;
setIsModal?: (isModel: boolean) => void;
addAccessibleChild?: (element: HTMLElement) => void;
addAccessibleChild?: (element: HTMLElement, pushToBeginning?: boolean) => void;
}

type MergedProps = InfoProps & ConnectProps & KeyboardA11yProps;
Expand All @@ -47,6 +47,7 @@ const translates = ({plays, creator}: InfoProps) => {
@withKeyboardA11y
@withText(translates)
export class Info extends Component<MergedProps> {
private _descriptionDivRed: HTMLDivElement | null = null;
renderMediaInfo = () => {
const {creator, createdAt, plays, creatorText, playsText} = this.props;

Expand Down Expand Up @@ -76,6 +77,18 @@ export class Info extends Component<MergedProps> {

componentDidMount(): void {
this.props.setIsModal && this.props.setIsModal(true);
this._addElementsToAccessibleList();
}

private _addElementsToAccessibleList(): void {
if (this._descriptionDivRed) {
const linkElements = Array.from(this._descriptionDivRed.querySelectorAll('a')).reverse();
linkElements.forEach(element => {
if (element.hasAttribute('href')) {
this.props.addAccessibleChild && this.props.addAccessibleChild(element! as HTMLElement, true);
}
});
}
}

render(props: MergedProps) {
Expand All @@ -92,7 +105,12 @@ export class Info extends Component<MergedProps> {
</div>
{this.renderMediaInfo()}
{description && (
<div data-testid="entryDescription" className={styles.entryDescription} dangerouslySetInnerHTML={{__html: sanitizeHtml(description)}} />
<div
data-testid="entryDescription"
className={styles.entryDescription}
dangerouslySetInnerHTML={{__html: sanitizeHtml(description)}}
ref={node => (this._descriptionDivRed = node)}
/>
)}
</div>
</Overlay>
Expand Down

0 comments on commit 982f812

Please sign in to comment.