Skip to content

Commit 8e62b64

Browse files
committed
fix(task-view): sync originalMarkdown when updating task content
- Update originalMarkdown field when task content changes in details panel - Check both content and originalMarkdown fields for UI updates - Fix task data propagation from filteredTasks to components - Ensure task title changes are reflected in list/tree views immediately Resolves issue where task title updates in details panel were not showing in the task list until a full refresh occurred.
1 parent 639325a commit 8e62b64

4 files changed

Lines changed: 36 additions & 17 deletions

File tree

src/components/task-view/content.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,22 +531,28 @@ export class ContentComponent extends Component {
531531

532532
// Option 1: Task still visible after filtering, update in place
533533
if (taskStillVisible) {
534+
// Find the updated task from filteredTasks (which has been refreshed from allTasks)
535+
const taskFromFiltered = this.filteredTasks.find(t => t.id === updatedTask.id);
536+
if (!taskFromFiltered) {
537+
return;
538+
}
539+
534540
// Find the rendered component and update it
535541
if (!this.isTreeView) {
536542
const component = this.taskComponents.find(
537543
(c) => c.getTask().id === updatedTask.id
538544
);
539-
component?.updateTask(updatedTask); // Update rendered component
545+
component?.updateTask(taskFromFiltered); // Update rendered component with filtered task
540546
} else {
541547
// For tree view, check root components and recursively search
542548
let updated = false;
543549
for (const rootComp of this.treeComponents) {
544550
if (rootComp.getTask().id === updatedTask.id) {
545-
rootComp.updateTask(updatedTask);
551+
rootComp.updateTask(taskFromFiltered);
546552
updated = true;
547553
break;
548554
} else {
549-
if (rootComp.updateTaskRecursively(updatedTask)) {
555+
if (rootComp.updateTaskRecursively(taskFromFiltered)) {
550556
updated = true;
551557
break;
552558
}

src/components/task-view/details.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,12 @@ export class TaskDetailsComponent extends Component {
509509
const updatedTask: Task = { ...task };
510510

511511
// Update task properties
512-
updatedTask.content = contentInput.getValue();
512+
const newContent = contentInput.getValue();
513+
updatedTask.content = newContent;
514+
// Also update originalMarkdown if content has changed
515+
if (task.content !== newContent) {
516+
updatedTask.originalMarkdown = newContent;
517+
}
513518

514519
// Update metadata properties
515520
const metadata = { ...updatedTask.metadata };
@@ -854,6 +859,7 @@ export class TaskDetailsComponent extends Component {
854859
// Compare key properties that can be edited in the form
855860
const compareProps = [
856861
"content",
862+
"originalMarkdown",
857863
"project",
858864
"tags",
859865
"context",

src/components/task-view/listItem.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -788,14 +788,16 @@ export class TaskListItemComponent extends Component {
788788
}
789789
}
790790

791-
// If only the content changed, just update the markdown
792-
if (oldTask.originalMarkdown !== task.originalMarkdown) {
793-
// Just re-render the markdown content
791+
// If content or originalMarkdown changed, update the markdown display
792+
if (oldTask.originalMarkdown !== task.originalMarkdown || oldTask.content !== task.content) {
793+
// Re-render the markdown content
794794
this.contentEl.empty();
795795
this.renderMarkdown();
796-
} else {
797-
// Full refresh needed for other changes
798-
this.updateTaskDisplay();
796+
}
797+
798+
// Check if metadata changed and update metadata display
799+
if (JSON.stringify(oldTask.metadata) !== JSON.stringify(task.metadata)) {
800+
this.renderMetadata();
799801
}
800802
}
801803

src/components/task-view/treeItem.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,15 +1020,20 @@ export class TaskTreeItemComponent extends Component {
10201020
}
10211021
}
10221022

1023-
// If only the content changed, just update the markdown
1024-
if (oldTask.originalMarkdown !== task.originalMarkdown) {
1025-
// Just re-render the markdown content
1023+
// If content or originalMarkdown changed, update the markdown display
1024+
if (oldTask.originalMarkdown !== task.originalMarkdown || oldTask.content !== task.content) {
1025+
// Re-render the markdown content
10261026
this.contentEl.empty();
10271027
this.renderMarkdown();
1028-
} else {
1029-
// Full refresh needed for other changes
1030-
this.element.empty();
1031-
this.onload();
1028+
}
1029+
1030+
// Check if metadata changed and need full refresh
1031+
if (JSON.stringify(oldTask.metadata) !== JSON.stringify(task.metadata)) {
1032+
// Re-render metadata
1033+
const metadataEl = this.parentContainer.querySelector('.task-metadata') as HTMLElement;
1034+
if (metadataEl) {
1035+
this.renderMetadata(metadataEl);
1036+
}
10321037
}
10331038
}
10341039

0 commit comments

Comments
 (0)