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