1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Focus on corresponding button

(cherry picked from commit 884ce171ea)
This commit is contained in:
Dmitry Lyzo 2023-05-23 00:40:37 +03:00
parent e7cb4ba670
commit 0381af80f1

View file

@ -1,4 +1,5 @@
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';
@ -258,9 +259,9 @@ export default function (view) {
let mouseIsDown = false; let mouseIsDown = false;
function showOsd() { function showOsd(focusElement) {
slideDownToShow(headerElement); slideDownToShow(headerElement);
showMainOsdControls(); showMainOsdControls(focusElement);
resetIdle(); resetIdle();
} }
@ -313,7 +314,9 @@ export default function (view) {
}); });
} }
function showMainOsdControls() { const _focus = debounce((focusElement) => focusManager.focus(focusElement), 50);
function showMainOsdControls(focusElement) {
if (!currentVisibleMenu) { if (!currentVisibleMenu) {
const elem = osdBottomElement; const elem = osdBottomElement;
currentVisibleMenu = 'osd'; currentVisibleMenu = 'osd';
@ -321,12 +324,14 @@ 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) {
setTimeout(function () { _focus(focusElement);
focusManager.focus(elem.querySelector('.btnPause'));
}, 50);
} }
toggleSubtitleSync(); toggleSubtitleSync();
} else if (currentVisibleMenu === 'osd' && focusElement && !layoutManager.mobile) {
_focus(focusElement);
} }
} }
@ -1174,15 +1179,19 @@ export default function (view) {
const key = keyboardnavigation.getKeyName(e); const key = keyboardnavigation.getKeyName(e);
const isKeyModified = e.ctrlKey || e.altKey || e.metaKey; const isKeyModified = e.ctrlKey || e.altKey || e.metaKey;
const btnPlayPause = osdBottomElement.querySelector('.btnPause');
if (e.keyCode === 32) { if (e.keyCode === 32) {
if (e.target.tagName !== 'BUTTON' || !layoutManager.tv) { if (e.target.tagName !== 'BUTTON' || !layoutManager.tv) {
playbackManager.playPause(currentPlayer); playbackManager.playPause(currentPlayer);
showOsd(btnPlayPause);
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
// Trick Firefox with a null element to skip next click // Trick Firefox with a null element to skip next click
clickedElement = null; clickedElement = null;
} } else {
showOsd(); showOsd();
}
return; return;
} }
@ -1205,7 +1214,7 @@ export default function (view) {
break; break;
case 'k': case 'k':
playbackManager.playPause(currentPlayer); playbackManager.playPause(currentPlayer);
showOsd(); showOsd(btnPlayPause);
break; break;
case 'ArrowUp': case 'ArrowUp':
case 'Up': case 'Up':
@ -1219,13 +1228,13 @@ export default function (view) {
case 'ArrowRight': case 'ArrowRight':
case 'Right': case 'Right':
playbackManager.fastForward(currentPlayer); playbackManager.fastForward(currentPlayer);
showOsd(); showOsd(btnFastForward);
break; break;
case 'j': case 'j':
case 'ArrowLeft': case 'ArrowLeft':
case 'Left': case 'Left':
playbackManager.rewind(currentPlayer); playbackManager.rewind(currentPlayer);
showOsd(); showOsd(btnRewind);
break; break;
case 'f': case 'f':
if (!e.ctrlKey && !e.metaKey) { if (!e.ctrlKey && !e.metaKey) {
@ -1253,7 +1262,7 @@ export default function (view) {
// Ignores gamepad events that are always triggered, even when not focused. // Ignores gamepad events that are always triggered, even when not focused.
if (document.hasFocus()) { /* eslint-disable-line compat/compat */ if (document.hasFocus()) { /* eslint-disable-line compat/compat */
playbackManager.rewind(currentPlayer); playbackManager.rewind(currentPlayer);
showOsd(); showOsd(btnRewind);
} }
break; break;
case 'NavigationRight': case 'NavigationRight':
@ -1262,7 +1271,7 @@ export default function (view) {
// Ignores gamepad events that are always triggered, even when not focused. // Ignores gamepad events that are always triggered, even when not focused.
if (document.hasFocus()) { /* eslint-disable-line compat/compat */ if (document.hasFocus()) { /* eslint-disable-line compat/compat */
playbackManager.fastForward(currentPlayer); playbackManager.fastForward(currentPlayer);
showOsd(); showOsd(btnFastForward);
} }
break; break;
case 'Home': case 'Home':