Skip to content

Commit 6a2a606

Browse files
committed
fix(TaskItem): use div instead of label element as task item wrapper
Fixes problems with more than one block node in task items. `label` elements have special click behaviour: clicking on them fires a second click on the their first "labelable" descendant. This resulted in weird bugs when having e.g. a code block or image as second block node in a task item. Fixes: #5225 Signed-off-by: Jonas <jonas@freesources.org>
1 parent 6e98e97 commit 6a2a606

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/css/prosemirror.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ div.ProseMirror {
7575
background-color: var(--color-primary-element);
7676
border-color: var(--color-primary-element);
7777
}
78-
> label > p {
78+
> .task-item-content > p {
7979
color: var(--color-text-maxcontrast);
8080
}
8181
}
82-
label {
82+
.task-item-content {
8383
display: block;
8484
flex-grow: 1;
8585
max-width: calc(100% - 28px);

src/nodes/TaskItem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const TaskItem = TipTapTaskItem.extend({
6262
'li',
6363
mergeAttributes(HTMLAttributes, listAttributes),
6464
['input', checkboxAttributes],
65-
['label', 0],
65+
['div', { class: 'task-item-content' }, 0],
6666
]
6767
},
6868

src/tests/tiptap.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('TipTap', () => {
3131
it('render taskList', () => {
3232
const markdown = '* [ ] item 1\n'
3333
expect(renderedHTML(markdown)).toEqual(
34-
'<ul class="contains-task-list"><li dir="ltr" data-checked="false" class="task-list-item checkbox-item"><input type="checkbox" class="" contenteditable="false"><label><p dir="ltr">item 1</p></label></li></ul>',
34+
'<ul class="contains-task-list"><li dir="ltr" data-checked="false" class="task-list-item checkbox-item"><input type="checkbox" class="" contenteditable="false"><div class="task-item-content"><p dir="ltr">item 1</p></div></li></ul>',
3535
)
3636
})
3737
})

0 commit comments

Comments
 (0)