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

This commit is contained in:
Dmitry Lyzo 2023-05-23 00:40:37 +03:00
parent 51bd2bef1a
commit 884ce171ea

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 SyncPlay from '../../../components/syncPlay/core'; import SyncPlay from '../../../components/syncPlay/core';
import browser from '../../../scripts/browser'; import browser from '../../../scripts/browser';
@ -217,9 +218,9 @@ import { appRouter } from '../../../components/appRouter';
let mouseIsDown = false; let mouseIsDown = false;
function showOsd() { function showOsd(focusElement) {
slideDownToShow(headerElement); slideDownToShow(headerElement);
showMainOsdControls(); showMainOsdControls(focusElement);
resetIdle(); resetIdle();
} }
@ -273,7 +274,9 @@ import { appRouter } from '../../../components/appRouter';
}); });
} }
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';
@ -281,12 +284,14 @@ import { appRouter } from '../../../components/appRouter';
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);
} }
} }
@ -1035,15 +1040,19 @@ import { appRouter } from '../../../components/appRouter';
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;
} }
@ -1066,7 +1075,7 @@ import { appRouter } from '../../../components/appRouter';
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':
@ -1080,13 +1089,13 @@ import { appRouter } from '../../../components/appRouter';
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) {
@ -1114,7 +1123,7 @@ import { appRouter } from '../../../components/appRouter';
// 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':
@ -1123,7 +1132,7 @@ import { appRouter } from '../../../components/appRouter';
// 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':