X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/0e528986abb94be2160b8d9c9d72a883a41bb60b..refs/pull/5312/head:/resources/js/services/keyboard-navigation.js diff --git a/resources/js/services/keyboard-navigation.js b/resources/js/services/keyboard-navigation.js index 9e05ef528..34111bb2d 100644 --- a/resources/js/services/keyboard-navigation.js +++ b/resources/js/services/keyboard-navigation.js @@ -57,6 +57,11 @@ export class KeyboardNavigationHandler { * @param {KeyboardEvent} event */ #keydownHandler(event) { + // Ignore certain key events in inputs to allow text editing. + if (event.target.matches('input') && (event.key === 'ArrowRight' || event.key === 'ArrowLeft')) { + return; + } + if (event.key === 'ArrowDown' || event.key === 'ArrowRight') { this.focusNext(); event.preventDefault(); @@ -66,7 +71,7 @@ export class KeyboardNavigationHandler { } else if (event.key === 'Escape') { if (this.onEscape) { this.onEscape(event); - } else if (document.activeElement) { + } else if (document.activeElement) { document.activeElement.blur(); } } else if (event.key === 'Enter' && this.onEnter) { @@ -80,10 +85,11 @@ export class KeyboardNavigationHandler { */ #getFocusable() { const focusable = []; - const selector = '[tabindex]:not([tabindex="-1"]),[href],button:not([tabindex="-1"]),input:not([type=hidden])'; + const selector = '[tabindex]:not([tabindex="-1"]),[href],button:not([tabindex="-1"],[disabled]),input:not([type=hidden])'; for (const container of this.containers) { - focusable.push(...container.querySelectorAll(selector)) + focusable.push(...container.querySelectorAll(selector)); } return focusable; } -} \ No newline at end of file + +}