From 2dcb367622648c6476bcc9f1bec18199e4e3c1e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=98=AD?= Date: Mon, 27 Jul 2026 13:48:32 +0800 Subject: [PATCH] fix: Fix quick data selection errors with Shift (#13374) * fix: Fix quick data selection errors with Shift * fix: Fix quick data selection errors with Shift --- .../components/table/complex/useTableSelection.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/table/complex/useTableSelection.ts b/frontend/src/components/table/complex/useTableSelection.ts index dfb0a6116..fc965874f 100644 --- a/frontend/src/components/table/complex/useTableSelection.ts +++ b/frontend/src/components/table/complex/useTableSelection.ts @@ -1,4 +1,4 @@ -import { ref, type Ref } from 'vue'; +import { shallowRef, ref, type Ref } from 'vue'; type TableRef = { refElTable?: any } | undefined; @@ -8,11 +8,12 @@ export const useTableSelection = ( onSelectionChange: (rows: any[]) => void, isRowSelectable: (row: any) => boolean = () => true, ) => { - const selectedRows = ref([]); + const selectedRows = shallowRef([]); const shiftPressed = ref(false); - const lastSelectedRow = ref(null); - const rangeBaseRows = ref([]); + const lastSelectedRow = shallowRef(null); + const rangeBaseRows = shallowRef([]); let isSyncingTableSelection = false; + let skipNextSelectionChange = false; const getTable = () => tableRef.value?.refElTable; const clearTextSelection = () => window.getSelection?.()?.removeAllRanges(); @@ -70,6 +71,11 @@ export const useTableSelection = ( if (isSyncingTableSelection) { return; } + if (skipNextSelectionChange) { + skipNextSelectionChange = false; + syncTableSelection(); + return; + } setSelectedRows(rows); if (rows.length === 0) { lastSelectedRow.value = null; @@ -78,6 +84,7 @@ export const useTableSelection = ( }; const handleSelect = (selection: any[], row: any) => { if (shiftPressed.value && applyRangeSelection(row)) { + skipNextSelectionChange = true; clearTextSelection(); return; }