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; }