decouple moving subtasks from navigation
Hunter
Friday, June 27th, 2025 at 12:28 AM
1003 updateTaskAndAncestors(currentParent);
1004 updateTaskAndAncestors(grandParent);
1005
- // Navigate to the outer layer (grandparent level)
- taskPath.pop(); // Remove current level
- currentTask = taskPath[taskPath.length - 1]; // Set to grandparent
-
- // Re-render the view
- renderCurrentView();
-
- // Focus on the moved subtask in its new location
- selectAndFocusTask(subtask);
1006 + // Handle view and selection based on remaining tasks at current level
1007 + if (currentParent.subtasks.length === 0 && taskPath.length > 1) {
1008 + // No remaining subtasks, navigate to parent level
1009 + navigateToParentTask();
1010 + } else {
1011 + // Stay at current level and select adjacent task
1012 + renderCurrentView();
1013 + if (currentParent.subtasks.length > 0) {
1014 + // Select the task that was above the moved one, or below if at the top
1015 + const targetIndex = Math.max(0, currentIndex - 1);
1016 + selectAndFocusTask(currentParent.subtasks[targetIndex]);
1017 + } else {
1018 + // Focus on the parent task if no subtasks remain
1019 + selectAndFocusTask(currentParent);
1020 + }
1021 + }
1022
1023 scheduleSave();
1024 }