(e: MouseEvent)
| 183 | }; |
| 184 | |
| 185 | const handleContextMenu = async (e: MouseEvent) => { |
| 186 | e.preventDefault(); |
| 187 | e.stopPropagation(); // Prevent event from bubbling to parent cards |
| 188 | |
| 189 | const selectionService = plugin.taskSelectionService; |
| 190 | |
| 191 | // Shift+right-click adds to selection and opens batch context menu |
| 192 | if (e.shiftKey && selectionService) { |
| 193 | if (!selectionService.isSelectionModeActive()) { |
| 194 | selectionService.enterSelectionMode(); |
| 195 | } |
| 196 | if (!selectionService.isSelected(task.path)) { |
| 197 | selectionService.addToSelection(task.path); |
| 198 | } |
| 199 | |
| 200 | // Show batch context menu if we have selections |
| 201 | if (selectionService.getSelectionCount() > 0) { |
| 202 | const menu = createBatchContextMenu?.(selectionService.getSelectedPaths(), () => {}); |
| 203 | menu?.show(e); |
| 204 | } |
| 205 | return; |
| 206 | } |
| 207 | |
| 208 | // Check if multiple tasks are selected - show batch context menu |
| 209 | if (selectionService && selectionService.getSelectionCount() > 1) { |
| 210 | // Ensure the right-clicked task is in the selection |
| 211 | if (!selectionService.isSelected(task.path)) { |
| 212 | selectionService.addToSelection(task.path); |
| 213 | } |
| 214 | |
| 215 | // Import and show batch context menu |
| 216 | const menu = createBatchContextMenu?.(selectionService.getSelectedPaths(), () => { |
| 217 | // Views will refresh via events |
| 218 | }); |
| 219 | menu?.show(e); |
| 220 | return; |
| 221 | } |
| 222 | |
| 223 | // Opening a single-task context menu exits selection mode |
| 224 | if (selectionService?.isSelectionModeActive()) { |
| 225 | selectionService.clearSelection(); |
| 226 | selectionService.exitSelectionMode(); |
| 227 | } |
| 228 | |
| 229 | if (contextMenuHandler) { |
| 230 | await contextMenuHandler(e); |
| 231 | } |
| 232 | }; |
| 233 | |
| 234 | const contextmenuHandler = (event: MouseEvent) => { |
| 235 | void handleContextMenu(event); |
no test coverage detected