Skip to content

Commit

Permalink
fix(player): focus on controls hide should not scroll
Browse files Browse the repository at this point in the history
closes #1182
  • Loading branch information
mihar-22 committed Mar 19, 2024
1 parent 53025a3 commit 778132f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/vidstack/src/core/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,15 @@ export class MediaControls extends MediaPlayerController {
}

private _init() {
const { viewType } = this.$state;

if (!this._canIdle()) return;

if (viewType() === 'audio') {
this.show();
return;
}

effect(this._watchMouse.bind(this));
effect(this._watchPaused.bind(this));

Expand Down Expand Up @@ -215,7 +222,9 @@ export class MediaControls extends MediaPlayerController {

if (!visible && document.activeElement && this.el?.contains(document.activeElement)) {
this._focusedItem = document.activeElement as HTMLElement;
requestAnimationFrame(() => this.el?.focus());
requestAnimationFrame(() => {
this.el?.focus({ preventScroll: true });
});
}

this.dispatch('controls-change', {
Expand Down

0 comments on commit 778132f

Please sign in to comment.