Markpad icon indicating copy to clipboard operation
Markpad copied to clipboard

Preview task checkboxes remain disabled in current Comrak output

Open PathGao opened this issue 4 months ago • 3 comments

Reproduced #148 in the current v2.6.14 macOS source build: an unsaved document containing - [ ] open task and - [x] completed task renders disabled checkboxes in split preview.

processTaskItems in src/lib/utils/markdown.ts now accepts a checkbox only when the input already has data-task-checkbox or the parent li has the task-list-item class. Current Comrak task-list HTML provides neither, so the routine never removes disabled or wires click handling.

Recognize the safe Comrak shape: a checkbox that is the first meaningful child of its list item, either directly or inside that list item’s first paragraph. Add a regression test using actual Comrak output and verify preview clicking changes the Markdown source.

PathGao avatar Jul 31 '26 07:07 PathGao

@alecdotdev #320 fixes the currently reproducible preview checklist regression. It records task-list provenance at the renderer boundary, keeps raw HTML controls inert, and updates the matching source line rather than relying on checkbox order. The PR is stacked after #318 and its predecessors; please review in that order.

PathGao avatar Jul 31 '26 07:07 PathGao

Fixed by #345. The Rust side stamps data-task-checkbox on the checkboxes comrak generates for task list items, and the frontend enables exactly those — so a raw HTML <input type=checkbox> in a document stays inert, which was the reason they were all disabled. #352 persists the toggle back to the source line. On master, not yet released.

PathGao avatar Aug 02 '26 21:08 PathGao

Closing — the premise this was filed on no longer holds.

The report was that processTaskItems only accepts a checkbox carrying data-task-checkbox or a parent li with task-list-item, and that comrak's task-list HTML supplies neither, so the routine never removes disabled or wires up the click.

The backend now supplies the marker. annotate_task_checkboxes (added in #345) inserts data-task-checkbox into comrak's output before the HTML reaches the frontend — 15 occurrences in src-tauri/src/lib.rs today — and src/lib/utils/markdown.ts:374 is the reader that accepts it. So the gap this describes is closed at the source rather than by relaxing the frontend's check.

Four later changes hardened the same path, all of them worth knowing about if this ever regresses:

  • #352 — a P0 where toggling a checkbox wrote - [x] into a code block. The fix made annotate_task_checkboxes cross-check against the raw buffer rather than the preprocessed text.
  • #389 — established that every preprocessing step in convert_markdown must map source line N to line N, with a registry test that fails if a step is added without being declared.
  • #426 — comrak 0.18 → 0.54 changed the attribute order from disabled="" checked="" to checked="" disabled="". TASK_ITEM_RE had spelled the old order out literally, so only completed checkboxes would have silently stopped being toggleable. The pattern now treats the boolean attributes as an unordered set.
  • #434 — convert_markdown copies its parameter to raw_buffer as its first statement, so a preprocessing step added at the top can no longer shadow the binding the #352 guard depends on.

scripts/renderProtocolFixtures.ts and scripts/renderProtocol.test.ts run the real convert_markdown output through the real processMarkdownHtml, so the end-to-end path is covered by execution rather than by a source-text assertion.

One caveat, stated plainly: none of this has shipped. The latest release is v2.6.13 (2026-07-30) and everything above landed after it. Anyone on a released build — or on the v2.6.14 source build this was reproduced against — will still see the old behaviour. If it turns out to still reproduce after the next release, please reopen; the fixture files above are the first place to look.

PathGao avatar Aug 03 '26 12:08 PathGao