diff --git a/changelog/unreleased/enhancement-add-keyboard-navigation-selection b/changelog/unreleased/enhancement-add-keyboard-navigation-selection index 70c09925e58..1672ee56f3b 100644 --- a/changelog/unreleased/enhancement-add-keyboard-navigation-selection +++ b/changelog/unreleased/enhancement-add-keyboard-navigation-selection @@ -13,4 +13,5 @@ We've added the possibility to navigate and select via keyboard. https://github.com/owncloud/web/pull/7153 https://github.com/owncloud/web/issues/6029 -https://github.com/owncloud/web/pull/7280 \ No newline at end of file +https://github.com/owncloud/web/pull/7280 +https://github.com/owncloud/web/pull/7283 \ No newline at end of file diff --git a/packages/web-app-files/src/components/FilesList/KeyboardActions.vue b/packages/web-app-files/src/components/FilesList/KeyboardActions.vue index 3c1c4688eb3..8d8d7245a11 100644 --- a/packages/web-app-files/src/components/FilesList/KeyboardActions.vue +++ b/packages/web-app-files/src/components/FilesList/KeyboardActions.vue @@ -71,14 +71,12 @@ export default defineComponent({ }), handleShortcut(event) { - event.preventDefault() const key = event.keyCode || event.which const ctrl = window.navigator.platform.match('Mac') ? event.metaKey : event.ctrlKey const shift = event.shiftKey this.handleFileActionsShortcuts(key, ctrl) this.handleFileSelectionShortcuts(key, shift, ctrl, event) - document.getElementById(this.keybindOnElementId).focus() }, handleFileActionsShortcuts(key, ctrl) { @@ -109,13 +107,18 @@ export default defineComponent({ handleNavigateAction(event, up = false) { event.preventDefault() - if (!this.latestSelectedId) return - const nextId = this.getNextResourceId(up) + let nextId + if (!this.latestSelectedId) { + nextId = this.getFirstResourceId() + } else { + nextId = this.getNextResourceId(up) + } if (nextId === -1) return this.resetSelectionCursor() this.resetFileSelection() this.addFileSelection({ id: nextId }) this.scrollToResource({ id: nextId }) + document.getElementById(this.keybindOnElementId).focus() }, handleShiftClickAction(resource) { @@ -215,8 +218,12 @@ export default defineComponent({ previous ? latestSelectedRow.previousSibling : latestSelectedRow.nextSibling ) as HTMLElement if (nextRow === null) return -1 - const nextResourceId = nextRow.getAttribute('data-item-id') - return nextResourceId + return nextRow.getAttribute('data-item-id') + }, + + getFirstResourceId() { + const firstRow = document.getElementsByClassName('oc-tbody-tr')[0] + return firstRow.getAttribute('data-item-id') } } })