From 87315ba91b8e8f667375692d2ad7c8719ec79919 Mon Sep 17 00:00:00 2001 From: Nick Sellen Date: Sat, 21 Dec 2024 12:11:55 +0000 Subject: [PATCH 1/2] fix(task-item): fix updating checked status --- packages/extension-task-item/src/task-item.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/extension-task-item/src/task-item.ts b/packages/extension-task-item/src/task-item.ts index cbb0a3f419..ab6e7c623d 100644 --- a/packages/extension-task-item/src/task-item.ts +++ b/packages/extension-task-item/src/task-item.ts @@ -202,12 +202,7 @@ export const TaskItem = Node.create({ return false } - listItem.dataset.checked = updatedNode.attrs.checked - if (updatedNode.attrs.checked) { - checkbox.setAttribute('checked', 'checked') - } else { - checkbox.removeAttribute('checked') - } + checkbox.checked = listItem.dataset.checked = updatedNode.attrs.checked return true }, From 1eabfc4456cac2b019ebe95c3a291fbbf00788d1 Mon Sep 17 00:00:00 2001 From: Nick the Sick Date: Mon, 30 Dec 2024 13:07:41 +0100 Subject: [PATCH 2/2] fix: add some more updates --- .changeset/orange-cows-pull.md | 5 +++++ packages/extension-task-item/src/task-item.ts | 7 +++---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 .changeset/orange-cows-pull.md diff --git a/.changeset/orange-cows-pull.md b/.changeset/orange-cows-pull.md new file mode 100644 index 0000000000..197d9621b1 --- /dev/null +++ b/.changeset/orange-cows-pull.md @@ -0,0 +1,5 @@ +--- +"@tiptap/extension-task-item": patch +--- + +Resolves an issue with the checkbox, where sometimes the check would not be properly updated diff --git a/packages/extension-task-item/src/task-item.ts b/packages/extension-task-item/src/task-item.ts index ab6e7c623d..03c38bf7b2 100644 --- a/packages/extension-task-item/src/task-item.ts +++ b/packages/extension-task-item/src/task-item.ts @@ -183,9 +183,7 @@ export const TaskItem = Node.create({ }) listItem.dataset.checked = node.attrs.checked - if (node.attrs.checked) { - checkbox.setAttribute('checked', 'checked') - } + checkbox.checked = node.attrs.checked checkboxWrapper.append(checkbox, checkboxStyler) listItem.append(checkboxWrapper, content) @@ -202,7 +200,8 @@ export const TaskItem = Node.create({ return false } - checkbox.checked = listItem.dataset.checked = updatedNode.attrs.checked + listItem.dataset.checked = updatedNode.attrs.checked + checkbox.checked = updatedNode.attrs.checked return true },