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-1335): Accessibility- “Close” button within the info video panel. #101

Merged
merged 1 commit into from
Jul 8, 2024
Merged
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
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
Loading