Skip to content

Commit fd819bf

Browse files
committed
plugin: fix duplicate task content rendering
If the task content was edited and then the query component refreshed, we would see both the previous and edited versions of the task content. This was because we would not clear the previous task content. There are a number of ways to resolve this, but the simplest is to key the component so we force a full remount when the content changes.
1 parent 6c4aefd commit fd819bf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

plugin/src/ui/query/task/Task.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ export const Task: React.FC<Props> = ({ tree }) => {
8383
<div />
8484
</Checkbox>
8585
<div className="todoist-task">
86-
<Markdown className="todoist-task-content" content={sanitizeContent(tree.content)} />
86+
<Markdown
87+
className="todoist-task-content"
88+
content={sanitizeContent(tree.content)}
89+
key={tree.content}
90+
/>
8791
{shouldRenderDescription && <DescriptionRenderer content={tree.description} />}
8892
<TaskMetadata query={query} task={tree} settings={settings} />
8993
</div>
@@ -156,7 +160,7 @@ const DescriptionRenderer: React.FC<DescriptionRendererProps> = ({ content }) =>
156160
return (
157161
<div onDoubleClick={toggleExpanded} className="todoist-task-description">
158162
{renderFullMarkdown ? (
159-
<Markdown content={content} />
163+
<Markdown content={content} key={content} />
160164
) : (
161165
<span>
162166
{content.split("\n")[0]}

0 commit comments

Comments
 (0)