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

Prevent Focus Loss When Skip Button is Pressed #6413

Open
wants to merge 7 commits into
base: release-10.10.z
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
3 changes: 0 additions & 3 deletions src/components/focusManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ function isCurrentlyFocusable(elem) {

if (elem.tagName === 'INPUT') {
const type = elem.type;
if (type === 'range') {
return false;
}
dmitrylyzo marked this conversation as resolved.
Show resolved Hide resolved
if (type === 'file') {
return false;
}
Expand Down
9 changes: 9 additions & 0 deletions src/components/playback/skipsegment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ interface ShowOptions {

function onHideComplete(this: HTMLButtonElement) {
if (this) {
// Handle focus after the hide transition completes
if (document.activeElement === this) {
this.blur();
const pauseButton = document.querySelector('.btnPause');
if (pauseButton && focusManager.isCurrentlyFocusable(pauseButton)) {
focusManager.focus(pauseButton);
}
}
Comment on lines +23 to +30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be considered as a temporary solution. We need to move the skip button to the video OSD (maybe in 10.11).


this.classList.add('hide');
}
}
Expand Down
19 changes: 15 additions & 4 deletions src/controllers/playback/video/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,13 @@ export default function (view) {
}

function slideDownToShow(elem) {
elem.classList.remove('hide');
dmitrylyzo marked this conversation as resolved.
Show resolved Hide resolved
elem.classList.remove('osdHeader-hidden');
}

function slideUpToHide(elem) {
elem.classList.add('osdHeader-hidden');
dmitrylyzo marked this conversation as resolved.
Show resolved Hide resolved
elem.addEventListener(transitionEndEventName, onHideAnimationComplete);
}

function clearHideAnimationEventListeners(elem) {
Expand All @@ -317,7 +319,7 @@ export default function (view) {

function onHideAnimationComplete(e) {
const elem = e.target;
if (elem != osdBottomElement) return;
if (elem !== osdBottomElement && elem !== headerElement) return;
elem.classList.add('hide');
elem.removeEventListener(transitionEndEventName, onHideAnimationComplete);
}
Expand All @@ -338,8 +340,17 @@ export default function (view) {
_focus(focusElement);
}
toggleSubtitleSync();
} else if (currentVisibleMenu === 'osd' && focusElement && !layoutManager.mobile) {
_focus(focusElement);
} else if (currentVisibleMenu === 'osd' && !layoutManager.mobile) {
// If no focus element is provided, try to keep current focus if it's valid,
// otherwise default to pause button
if (!focusElement) {
const currentFocus = document.activeElement;
if (!currentFocus || !focusManager.isCurrentlyFocusable(currentFocus)) {
focusElement = osdBottomElement.querySelector('.btnPause');
}
}

if (focusElement) _focus(focusElement);
}
}

Expand All @@ -354,7 +365,7 @@ export default function (view) {
toggleSubtitleSync('hide');

// Firefox does not blur by itself
if (document.activeElement) {
if (document.activeElement && !focusManager.isCurrentlyFocusable(document.activeElement)) {
dmitrylyzo marked this conversation as resolved.
Show resolved Hide resolved
document.activeElement.blur();
}
}
Expand Down
Loading