Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(task-item): fix updating checked status #5953

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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