Skip to content

Commit

Permalink
ADA-2294 - Disable controls with styling
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinStoicaK committed Mar 4, 2025
1 parent 7150937 commit 761f903
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
9 changes: 9 additions & 0 deletions src/components/offline/offline.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,12 @@
}
}
}

:global {
.controls-hidden .playkit-top-bar,
.controls-hidden .playkit-bottom-bar,
.controls-hidden .playkit-playback-controls,
.controls-hidden .playkit-center-playback-controls {
display: none !important;
}
}
31 changes: 12 additions & 19 deletions src/components/offline/offline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,18 @@ export class Offline extends Component<OfflineProps, OfflineState> {
return this.props.postBroadcast ? null : this.props.offlineBody;
}

private originalTabIndexes: Map<HTMLElement, number | null> = new Map();

private disableGuiFocus() {
const guiAreaElements = document.querySelectorAll('.playkit-gui-area *');
guiAreaElements.forEach((element) => {
if (element instanceof HTMLElement && (element.tagName === 'button' || element.tagName === 'a' || element.hasAttribute('tabindex'))) {
this.originalTabIndexes.set(element, element.tabIndex);
element.tabIndex = -1;
}
});
private disableControls() {
const guiContainer = document.querySelector('.playkit-gui-area');
if (guiContainer) {
guiContainer.classList.add('controls-hidden');
}
}

private restoreGuiFocus() {
this.originalTabIndexes.forEach((tabIndex, element) => {
if (element) {
element.tabIndex = tabIndex ?? 0;
}
});
this.originalTabIndexes.clear();
private restoreControls() {
const guiContainer = document.querySelector('.playkit-gui-area');
if (guiContainer) {
guiContainer.classList.remove('controls-hidden');
}
}

componentDidMount(): void {
Expand All @@ -90,15 +83,15 @@ export class Offline extends Component<OfflineProps, OfflineState> {
this._backgroundPlayer.muted = player.muted;
this._backgroundPlayer.play();
}
this.disableGuiFocus();
this.disableControls();
}

componentWillUnmount(): void {
if (this._backgroundPlayer) {
this._backgroundPlayer.pause();
this._originalVideoElementParent!.prepend(this._backgroundPlayer.getVideoElement());
}
this.restoreGuiFocus();
this.restoreControls();
}

private _handleMute = (): void => {
Expand Down

0 comments on commit 761f903

Please sign in to comment.