You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Markdown checkboxes toggle incorrect ones if they start with the same text #7113
If you create multiple markdown checkboxes with the same text, when you click on one, it toggles the first checkbox before the one you clicked with that same text (that is in the same toggle state) instead of the one you clicked.
Reproduce the Bug
Create a block with this text (in markdown file mode):
necessary first line
* [ ] thing
* [ ] thing
* [ ] thing
Then click on the 2nd or 3rd checkboxes multiple times and observe that the one you click isn't necessarily the one that gets toggled.
Expected Behavior
The one you click is the one that should toggle.
Screenshots
Screen.Recording.2022-10-26.at.12.07.31.mov
Desktop Platform Information
macOS 12.5, Logseq Version 0.8.9
Mobile Platform Information
No response
Additional Context
The logic seems to include any line that starts with the same text as the line being clicked on, even if also has other text after it:
necessary first line
* [ ] thing
* [ ] thing2
* [ ] t
changed the title [-]Markdown checkboxes toggle incorrectly if they have the same text[/-][+]Markdown checkboxes toggle incorrect ones if they have the same text[/+]on Oct 26, 2022
changed the title [-]Markdown checkboxes toggle incorrect ones if they have the same text[/-][+]Markdown checkboxes toggle incorrect ones if they start with the same text[/+]on Oct 26, 2022
The behavior is that if I check a box in a block, this on-change event listener will compute the new content based on the content of checkbox item. And call the following function that replaces the first matched string of this block.
necessary first line
* [ ] thing
* [ ] thing
* [ ] thing
When I click the last checkbox, the codes will recognize that the status checked of the target checkbox turns to true and compute the result item-full-content="[ ] thing" and new-item-full-content="[X] thing". These result will be passed as parameters to function toggle-list-checkbox which replaces the first matched string of the block.
Hence getting the block
necessary first line
* [X] thing
* [ ] thing
* [ ] thing
But not what I expect.
necessary first line
* [ ] thing
* [ ] thing
* [X] thing
Also if a checkbox starts with a link (or contains only a link), the wrong checkboxes are marked.
What happened?
When checking off checkboxes that start with a link or contain only a link, the wrong checkboxes are marked (from top to bottom).
Reproduce the Bug
Create a block with this text (in markdown file mode):
## Checklist
* [ ] Checkbox 1
* [ ] Checkbox 2
* [ ] Checkbox 3
* [ ] Checkbox 4
* [ ] Checkbox 5
* [ ] [[Just a link without text before or behind (doesn't work correctly)]]
* [ ] [[Link to some page]] with text behind (doesn't work)
* [ ] Text before a [[link to some page]] (works fine)
Then click several times second and third last checkboxes and notice that the box you clicked is not necessarily the one that is toggled.
@phoenixeliot I think in your last post the cause of the misbehavior is at the beginning of line 1 & 4 with the same word ‘Mattress’. Could you rename the fourth entry to ‘Another Mattress’ for testing purposes, and then try again?
This is still an issue, but the fix involves complicated tree traversal of the generated HTML to identify which checkbox was clicked (currently it is done via a text search, which is the root cause for the wrong one getting ticked).
I would imagine it will be easier to fix after #9858 is merged
Activity
[-]Markdown checkboxes toggle incorrectly if they have the same text[/-][+]Markdown checkboxes toggle incorrect ones if they have the same text[/+][-]Markdown checkboxes toggle incorrect ones if they have the same text[/-][+]Markdown checkboxes toggle incorrect ones if they start with the same text[/+]situ2001 commentedon Oct 27, 2022
I can reproduce this bug, too. I found the logic of code segment related to list-checkbox.
logseq/src/main/frontend/components/block.cljs
Lines 1512 to 1523 in 06465e6
The behavior is that if I check a box in a block, this
on-changeevent listener will compute the new content based on the content of checkbox item. And call the following function that replaces the first matched string of this block.logseq/src/main/frontend/handler/editor.cljs
Lines 2342 to 2345 in 06465e6
item-full-content.For example, if I create a list like this.
When I click the last checkbox, the codes will recognize that the status
checkedof the target checkbox turns totrueand compute the resultitem-full-content="[ ] thing"andnew-item-full-content="[X] thing". These result will be passed as parameters to functiontoggle-list-checkboxwhich replaces the first matched string of the block.Hence getting the block
But not what I expect.
situ2001 commentedon Oct 27, 2022
If the content of every items are not the same. Everything goes well.
Kapture.2022-10-27.at.12.30.31.mp4
m1aw commentedon Nov 30, 2022
To add some more information on this ticket. If the text starts with the same markup element a similar behaviour happens. In example:
JustAnotherTill commentedon Mar 5, 2023
Also if a checkbox starts with a link (or contains only a link), the wrong checkboxes are marked.
What happened?
When checking off checkboxes that start with a link or contain only a link, the wrong checkboxes are marked (from top to bottom).
Reproduce the Bug
Create a block with this text (in markdown file mode):
Then click several times second and third last checkboxes and notice that the box you clicked is not necessarily the one that is toggled.
Expected Behavior
The one you click is the one that should toggle.
cnrpman commentedon May 24, 2023
The content-based implementation is really awful 🤣
PR is welcome.
rjdverbeek-tud commentedon Apr 8, 2024
Is also reported als a bug report on the discussion forum.
https://discuss.logseq.com/t/checking-checkbox-but-other-checkbox-is-checked/25521
phoenixeliot commentedon May 28, 2024
Forgot about and rediscovered this bug again. Sharing this video of slightly different buggy behavior for the record.
Screen.Recording.2024-05-28.at.00.42.12.mov
JustAnotherTill commentedon May 28, 2024
@phoenixeliot I think in your last post the cause of the misbehavior is at the beginning of line 1 & 4 with the same word ‘Mattress’. Could you rename the fourth entry to ‘Another Mattress’ for testing purposes, and then try again?
dm-canteen commentedon Jun 30, 2024
I have been annoyed by this for a while too; you cannot toggle checkboxes which are italic or bold:

reddiewalsh commentedon Nov 16, 2024
I'm able to replicate the same/similar bugs in org-mode:
Screencast.From.2024-11-16.11-02-16.webm
This is my first time posting about a bug, so let me know if I need to make a separate issue for this.
dm-canteen commentedon Nov 20, 2024
This is still an issue, but the fix involves complicated tree traversal of the generated HTML to identify which checkbox was clicked (currently it is done via a text search, which is the root cause for the wrong one getting ticked).
I would imagine it will be easier to fix after #9858 is merged
quinn-p-mchugh commentedon Aug 6, 2025
Update: #9858 was merged on May 29th.
Would love to see this fixed. Anyone interested in working on PR?