From f013e1cf25fa5f0862cfe96af1bbb42fb3c4c872 Mon Sep 17 00:00:00 2001 From: indigo Date: Sat, 18 Jul 2026 13:19:42 +0800 Subject: [PATCH] Fix wrong selected-task count in the task bulk-actions context menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit handleContextMenu (and the shift-click range-selection path) resolved the target row via props.tasks[index], but index is the row's position in the sorted/rendered row model (table.getRowModel().rows), not the raw prop array — the two orders rarely match once the default created_at sort is applied. This caused right-click (and shift-click) to select the wrong row, corrupting the count shown in TaskBulkActionsMenu. Both call sites now resolve the task from the actual row data instead of an index lookup into the unsorted array, matching the pattern ShotsDataTable.vue already used correctly. Co-Authored-By: Claude Sonnet 5 --- .../src/components/task/TasksDataTable.vue | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/frontend/src/components/task/TasksDataTable.vue b/frontend/src/components/task/TasksDataTable.vue index 8934b21..1a60c06 100644 --- a/frontend/src/components/task/TasksDataTable.vue +++ b/frontend/src/components/task/TasksDataTable.vue @@ -34,7 +34,7 @@ ]" @click="handleRowClick(row.original, $event, index)" @dblclick="handleRowDoubleClick(row.original)" - @contextmenu="handleContextMenu($event, index)" + @contextmenu="handleContextMenu($event, row.original)" > { const end = Math.max(lastClickedIndex.value, index) const newSelection: Record = {} + // Index into the sorted/rendered row model, not props.tasks — the raw prop array + // order doesn't match the displayed (sorted) order. + const displayedRows = table.getRowModel().rows for (let i = start; i <= end; i++) { - const id = String(props.tasks[i].id) + const id = String(displayedRows[i].original.id) newSelection[id] = true } // Update rowSelection - create completely new object to trigger reactivity rowSelection.value = newSelection - console.log('Shift-click selection updated:', rowSelection.value) lastClickedIndex.value = index } else if (event.ctrlKey || event.metaKey) { // Ctrl/Cmd+Click: Toggle selection @@ -252,17 +254,9 @@ const handleRowDoubleClick = (task: Task) => { emit('row-double-click', task) } -const handleContextMenu = (event: MouseEvent, index: number) => { +const handleContextMenu = (event: MouseEvent, rightClickedTask: Task) => { event.preventDefault() - // Prevent context menu on empty table areas - if (props.tasks.length === 0) { - return - } - - const rightClickedTask = props.tasks[index] - if (!rightClickedTask) return - const taskId = String(rightClickedTask.id) // If right-clicked row is not selected, add it to selection