From dbcdaad30ab719a0e4eb88da17ef4fffdcb4661a Mon Sep 17 00:00:00 2001 From: Jarle Friestad Date: Tue, 20 Aug 2024 16:54:16 +0200 Subject: [PATCH] fix(task-item): prevent onBlur being trigged when toggled (#5520) --- .changeset/slow-lies-promise.md | 5 +++++ packages/extension-task-item/src/task-item.ts | 1 + 2 files changed, 6 insertions(+) create mode 100644 .changeset/slow-lies-promise.md diff --git a/.changeset/slow-lies-promise.md b/.changeset/slow-lies-promise.md new file mode 100644 index 000000000..678dda212 --- /dev/null +++ b/.changeset/slow-lies-promise.md @@ -0,0 +1,5 @@ +--- +"@tiptap/extension-task-item": patch +--- + +Prevent `onBlur` from being trigged when a task item is toggled diff --git a/packages/extension-task-item/src/task-item.ts b/packages/extension-task-item/src/task-item.ts index 3155cb87b..cbb0a3f41 100644 --- a/packages/extension-task-item/src/task-item.ts +++ b/packages/extension-task-item/src/task-item.ts @@ -137,6 +137,7 @@ export const TaskItem = Node.create({ checkboxWrapper.contentEditable = 'false' checkbox.type = 'checkbox' + checkbox.addEventListener('mousedown', event => event.preventDefault()) checkbox.addEventListener('change', event => { // if the editor isn’t editable and we don't have a handler for // readonly checks we have to undo the latest change