From 2b1000ca60ae5c8067bb074b3c229b76c62948df Mon Sep 17 00:00:00 2001 From: Jannik Stehle <50302941+JammingBen@users.noreply.github.com> Date: Tue, 2 Jul 2024 10:50:01 +0200 Subject: [PATCH] fix: keyboard navigation breaking (#11099) Fixes the keyboard navigation breaking in certain scenarios. The issue was that `window.getSelection()` would not always return the currently focused element when checking if we need to disable our custom keybindings. So e.g. when clicking the search input and then clicking a file in the file list, the focused element would still be the search input, leading to our keybindings not working. --- changelog/unreleased/bugfix-keyboard-navigation-breaking | 6 ++++++ .../src/composables/keyboardActions/useKeyboardActions.ts | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 changelog/unreleased/bugfix-keyboard-navigation-breaking diff --git a/changelog/unreleased/bugfix-keyboard-navigation-breaking b/changelog/unreleased/bugfix-keyboard-navigation-breaking new file mode 100644 index 00000000000..3d62ac8a0fa --- /dev/null +++ b/changelog/unreleased/bugfix-keyboard-navigation-breaking @@ -0,0 +1,6 @@ +Bugfix: Keyboard navigation breaking + +We've fixed a bug where the keyboard navigation would break in certain scenarios, e.g. when opening a folder from the search results. + +https://github.com/owncloud/web/issues/10942 +https://github.com/owncloud/web/pull/11099 diff --git a/packages/web-pkg/src/composables/keyboardActions/useKeyboardActions.ts b/packages/web-pkg/src/composables/keyboardActions/useKeyboardActions.ts index 304713f6798..4d2593442bb 100644 --- a/packages/web-pkg/src/composables/keyboardActions/useKeyboardActions.ts +++ b/packages/web-pkg/src/composables/keyboardActions/useKeyboardActions.ts @@ -49,11 +49,11 @@ const areCustomKeyBindingsDisabled = () => { ) { return true } - const closestSelectionEl = window.getSelection().focusNode as HTMLElement + const closestSelectionEl = document.activeElement if (!closestSelectionEl) { return false } - let customKeyBindings + let customKeyBindings: Element try { customKeyBindings = closestSelectionEl?.closest("[data-custom-key-bindings-disabled='true']") } catch {