mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Fix re-focusing on pause button when displaying OSD
When focus is debounced, `document.activeElement` is not updated immediately, and someone (skipsegment.ts) might read it too early. Remove focus debounce to immediately update `document.activeElement`. This (undebounced focus) seems to work in webOS 1.2, webOS 5, Firefox 134, Chrome 132. So the timeout was probably for Internet Explorer.
This commit is contained in:
parent
2ab61b6d7b
commit
fb47403b72
1 changed files with 11 additions and 14 deletions
|
@ -1,5 +1,4 @@
|
||||||
import escapeHtml from 'escape-html';
|
import escapeHtml from 'escape-html';
|
||||||
import debounce from 'lodash-es/debounce';
|
|
||||||
import { playbackManager } from '../../../components/playback/playbackmanager';
|
import { playbackManager } from '../../../components/playback/playbackmanager';
|
||||||
import browser from '../../../scripts/browser';
|
import browser from '../../../scripts/browser';
|
||||||
import dom from '../../../scripts/dom';
|
import dom from '../../../scripts/dom';
|
||||||
|
@ -326,7 +325,16 @@ export default function (view) {
|
||||||
elem.removeEventListener(transitionEndEventName, onHideAnimationComplete);
|
elem.removeEventListener(transitionEndEventName, onHideAnimationComplete);
|
||||||
}
|
}
|
||||||
|
|
||||||
const _focus = debounce((focusElement) => focusManager.focus(focusElement), 50);
|
const _focus = function (focusElement) {
|
||||||
|
// If no focus element is provided, try to keep current focus if it's valid,
|
||||||
|
// otherwise default to pause button
|
||||||
|
const currentFocus = focusElement || document.activeElement;
|
||||||
|
if (!currentFocus || !focusManager.isCurrentlyFocusable(currentFocus)) {
|
||||||
|
focusElement = osdBottomElement.querySelector('.btnPause');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (focusElement) focusManager.focus(focusElement);
|
||||||
|
};
|
||||||
|
|
||||||
function showMainOsdControls(focusElement) {
|
function showMainOsdControls(focusElement) {
|
||||||
if (!currentVisibleMenu) {
|
if (!currentVisibleMenu) {
|
||||||
|
@ -336,23 +344,12 @@ export default function (view) {
|
||||||
elem.classList.remove('hide');
|
elem.classList.remove('hide');
|
||||||
elem.classList.remove('videoOsdBottom-hidden');
|
elem.classList.remove('videoOsdBottom-hidden');
|
||||||
|
|
||||||
focusElement ||= elem.querySelector('.btnPause');
|
|
||||||
|
|
||||||
if (!layoutManager.mobile) {
|
if (!layoutManager.mobile) {
|
||||||
_focus(focusElement);
|
_focus(focusElement);
|
||||||
}
|
}
|
||||||
toggleSubtitleSync();
|
toggleSubtitleSync();
|
||||||
} else if (currentVisibleMenu === 'osd' && !layoutManager.mobile) {
|
} else if (currentVisibleMenu === 'osd' && !layoutManager.mobile) {
|
||||||
// If no focus element is provided, try to keep current focus if it's valid,
|
_focus(focusElement);
|
||||||
// otherwise default to pause button
|
|
||||||
if (!focusElement) {
|
|
||||||
const currentFocus = document.activeElement;
|
|
||||||
if (!currentFocus || !focusManager.isCurrentlyFocusable(currentFocus)) {
|
|
||||||
focusElement = osdBottomElement.querySelector('.btnPause');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (focusElement) _focus(focusElement);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue