From 72d435b8c323b1f1446061c3491451ce456847c2 Mon Sep 17 00:00:00 2001 From: Paul Neubauer Date: Tue, 9 May 2023 16:23:51 +0200 Subject: [PATCH] Bugfix: Keyboard shift + click selection selects file double (#9003) --- .../src/components/FilesList/KeyboardActions.vue | 5 ++++- .../web-app-files/src/components/FilesList/ResourceTable.vue | 5 +++-- .../tests/unit/components/FilesList/KeyboardActions.spec.ts | 5 ++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/web-app-files/src/components/FilesList/KeyboardActions.vue b/packages/web-app-files/src/components/FilesList/KeyboardActions.vue index edf8135211a..c6f686c6440 100644 --- a/packages/web-app-files/src/components/FilesList/KeyboardActions.vue +++ b/packages/web-app-files/src/components/FilesList/KeyboardActions.vue @@ -167,7 +167,7 @@ export default defineComponent({ scrollToResource({ id: nextResourceId } as any) selectionCursor.value = unref(selectionCursor) + 1 } - const handleShiftClickAction = (resource) => { + const handleShiftClickAction = ({ resource, skipTargetSelection }) => { const parent = document.querySelectorAll(`[data-item-id='${resource.id}']`)[0] const resourceNodes = Object.values(parent.parentNode.children) const latestNode = resourceNodes.find( @@ -184,6 +184,9 @@ export default defineComponent({ for (let i = minIndex; i <= maxIndex; i++) { const nodeId = resourceNodes[i].getAttribute('data-item-id') + if (skipTargetSelection && nodeId === resource.id) { + continue + } store.commit('Files/ADD_FILE_SELECTION', { id: nodeId }) } store.commit('Files/SET_LATEST_SELECTED_FILE_ID', resource.id) diff --git a/packages/web-app-files/src/components/FilesList/ResourceTable.vue b/packages/web-app-files/src/components/FilesList/ResourceTable.vue index 23e457923b2..44cce0becca 100644 --- a/packages/web-app-files/src/components/FilesList/ResourceTable.vue +++ b/packages/web-app-files/src/components/FilesList/ResourceTable.vue @@ -47,7 +47,7 @@ :model-value="isResourceSelected(item)" :outline="isLatestSelectedItem(item)" @update:model-value="setSelection($event, item)" - @click.stop="fileClicked([item, $event])" + @click.stop="fileClicked([item, $event, true])" />