Skip to content

Commit

Permalink
fix(task-item): fix updating checked status (#5953)
Browse files Browse the repository at this point in the history
* fix(task-item): fix updating checked status

* fix: add some more updates

---------

Co-authored-by: Nick the Sick <[email protected]>
  • Loading branch information
nicksellen and nperez0111 authored Dec 30, 2024
1 parent 4530606 commit d1b7dd2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/orange-cows-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tiptap/extension-task-item": patch
---

Resolves an issue with the checkbox, where sometimes the check would not be properly updated
10 changes: 2 additions & 8 deletions packages/extension-task-item/src/task-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ export const TaskItem = Node.create<TaskItemOptions>({
})

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)
Expand All @@ -203,11 +201,7 @@ export const TaskItem = Node.create<TaskItemOptions>({
}

listItem.dataset.checked = updatedNode.attrs.checked
if (updatedNode.attrs.checked) {
checkbox.setAttribute('checked', 'checked')
} else {
checkbox.removeAttribute('checked')
}
checkbox.checked = updatedNode.attrs.checked

return true
},
Expand Down

0 comments on commit d1b7dd2

Please sign in to comment.