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

Fix keyboard navigation for INPUT and TEXTAREA

This commit is contained in:
Dmitry Lyzo 2022-11-10 16:30:32 +03:00
parent de8ee44b22
commit 36fce00270

View file

@ -44,6 +44,11 @@ const KeyNames = {
*/
const NavigationKeys = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'];
/**
* Elements for which navigation should be constrained.
*/
const InteractiveElements = ['INPUT', 'TEXTAREA'];
let hasFieldKey = false;
try {
hasFieldKey = 'key' in new KeyboardEvent('keydown');
@ -91,13 +96,21 @@ export function enable() {
switch (key) {
case 'ArrowLeft':
if (!InteractiveElements.includes(document.activeElement?.tagName)) {
inputManager.handleCommand('left');
} else {
capture = false;
}
break;
case 'ArrowUp':
inputManager.handleCommand('up');
break;
case 'ArrowRight':
if (!InteractiveElements.includes(document.activeElement?.tagName)) {
inputManager.handleCommand('right');
} else {
capture = false;
}
break;
case 'ArrowDown':
inputManager.handleCommand('down');