Skip to content

fix(core): keep the children of a toggle list item in the HTML export and parse - #3388

Merged
nperez0111 merged 3 commits into
mainfrom
fix/toggle-list-item-html-children
Nov 25, 2026
Merged

nperez0111 merged 3 commits into
mainfrom
fix/toggle-list-item-html-children

Conversation

@YousefED

@YousefED YousefED commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

An HTML export and parse of a toggle list item with list items as children gave the wrong blocks. Two faults caused this.

  1. The parse read a toggle list item as a check list item when a check list item was in the <details> element of the toggle. The parse rule of the check list item found the checkbox of the child. The rule now uses only a checkbox whose nearest <li> element is the list item itself.
  2. The export (blocksToHTMLLossy) moved the list items at the start of the children of a toggle behind the other children, and out of the <details> element. The parse then read them as top-level blocks. Now all the children of a block with a childrenDOM go there, in their order.

Fix 2 needs fix 1: a check list item that is the first child is now in the <details> element.

Testing

  • Three new cases in the format tests. They fail on main.
  • The unit and format tests pass. No browser run was made locally.

Notes

  • Merge after the list parse pull request (not open yet). Without it, the markdown round trip of a toggle with list children and then a paragraph has a different loss than on main: the paragraph becomes a bullet at the top level.
  • The HTML of a toggle list item with only list items as children changes: the nested list is now in the <details> element.

Summary by CodeRabbit

  • Bug Fixes
    • Nested lists now remain in their intended position when exporting HTML, including within toggle-list content.
    • Checklist parsing correctly identifies the checkbox for each list item, even when nested items also contain checkboxes.
  • Tests
    • Added coverage for HTML conversion of toggle lists with mixed nested content and checked checklist items.

The fault: the HTML parse read a toggle list item as a check list item
if a check list item was in the `<details>` element of the toggle. The
toggle also got the `checked` value of that child.

The cause: the parse rule of the check list item searched the full
`<li>` element for a checkbox. Thus it also found the checkbox of a list
item that is nested in the `<li>`. The parser moves a nested list out of
its `<li>` before the rules run, but not if the list is in another
element, such as `<details>`.

The fix: the rule uses only a checkbox whose nearest `<li>` ancestor is
the list item itself.
…e HTML export

The fault: `blocksToHTMLLossy` changed the order of the children of a
toggle list item. If the first children were list items, the export put
them after the other children, and outside of the `<details>` element.
The HTML parse then read some of them as top-level blocks.

The cause: the serializer first moves the nested lists at the start of
the children of a list item into its `<li>`. Only after that, it puts
the remaining children in the place that the block gives (`childrenDOM`,
the `<details>` of a toggle).

The fix: a block that gives a place for its children gets all of its
children there, in their order. The move of the nested lists into the
`<li>` now applies only to a block without such a place.

A check list item as the first child is now inside the `<details>` of
the toggle. This needs the fix "parse a toggle with a check list child
as a toggle": without it, the parse reads the toggle as a check list
item. Thus this change comes after that fix. A test has this case.
@vercel

vercel Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
blocknote Ready Ready Preview Nov 24, 2026 1:40pm UTC
blocknote-website Ready Ready Preview Nov 24, 2026 1:40pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

HTML serialization now preserves nested lists in an explicit child destination. Checklist parsing selects the checkbox belonging to the current list item. New parse fixtures and round-trip cases cover nested toggle-list children.

Changes: Toggle list HTML handling

Layer / File(s) Summary
Nested toggle-list HTML handling
packages/core/src/api/exporters/html/util/serializeBlocksExternalHTML.ts, packages/core/src/blocks/ListItem/CheckListItem/block.ts, tests/src/integration/formatConversion/parse/parseTestInstances.ts, tests/src/integration/formatConversion/exportParseEquality/exportParseEqualityTestInstances.ts
Serialization keeps nested lists in an explicit child destination. Checklist parsing selects a checkbox whose closest <li> is the current item. New fixtures cover nested checklist items and toggle-list children with mixed content.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: nperez0111, matthewlipski

Merge Risk: Minimal · up to 86743 · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix (core) and the affected area: keeping toggle list item children in the HTML export and parse. The changeset matches this. The title is specific and describes the main change, t…
Description check Passed The description follows the template sections Summary, Testing, and Notes. It explains the two faults and the fixes, the new tests, and the merge dependency. It lacks the Rationale, Impact, Screenshot…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the fix (core) and the affected area: keeping toggle list item children in the HTML export and parse. The changeset matches this. The title is specific and describes the main change, though it is long at 79 characters.

Full details: Description check

Explanation

The description follows the template sections Summary, Testing, and Notes. It explains the two faults and the fixes, the new tests, and the merge dependency. It lacks the Rationale, Impact, Screenshots/Video, Checklist, and Additional Notes headings. The Impact content appears in Notes, and the rationale is implied by the Summary. Required information is mostly present.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the list with care,
A nested box is handled there.
The child lists stay in their place,
Round-trip tests retrace their trace.
The checked item gets its turn,
While little paws review and learn.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9bce1e8a-82f7-4325-bbe3-4080b31b4656
Commits

Reviewing files that changed from the base of the PR and between 6d8850f and 867437f.

Files ignored due to path filters: 1

  • tests/src/integration/formatConversion/parse/__snapshots__/html/toggleListItemWithCheckListChild.json is excluded by !**/__snapshots__/**
Files selected for processing: 2

  • tests/src/integration/formatConversion/exportParseEquality/exportParseEqualityTestInstances.ts
  • tests/src/integration/formatConversion/parse/parseTestInstances.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@pkg-pr-new

pkg-pr-new Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/@blocknote/ariakit@3388

@blocknote/code-block

npm i https://pkg.pr.new/@blocknote/code-block@3388

@blocknote/core

npm i https://pkg.pr.new/@blocknote/core@3388

@blocknote/diagram-block

npm i https://pkg.pr.new/@blocknote/diagram-block@3388

@blocknote/mantine

npm i https://pkg.pr.new/@blocknote/mantine@3388

@blocknote/math-block

npm i https://pkg.pr.new/@blocknote/math-block@3388

@blocknote/react

npm i https://pkg.pr.new/@blocknote/react@3388

@blocknote/server-util

npm i https://pkg.pr.new/@blocknote/server-util@3388

@blocknote/shadcn

npm i https://pkg.pr.new/@blocknote/shadcn@3388

@blocknote/xl-ai

npm i https://pkg.pr.new/@blocknote/xl-ai@3388

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/@blocknote/xl-docx-exporter@3388

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/@blocknote/xl-email-exporter@3388

@blocknote/xl-multi-column

npm i https://pkg.pr.new/@blocknote/xl-multi-column@3388

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/@blocknote/xl-odt-exporter@3388

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/@blocknote/xl-pdf-exporter@3388

@blocknote/xl-typst-exporter

npm i https://pkg.pr.new/@blocknote/xl-typst-exporter@3388

commit: 867437f

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.2
Preview removed because the pull request was closed.
2026-11-25 11:48 UTC

@YousefED
YousefED marked this pull request as ready for review November 21, 2026 19:28
@nperez0111
nperez0111 merged commit c0271a4 into main Nov 25, 2026
37 checks passed
@nperez0111
nperez0111 deleted the fix/toggle-list-item-html-children branch November 25, 2026 11:48

This branch was successfully deployed

2 active deployments
Preview – blocknote-website — 867437f6 Deployed Nov 24, 2026 by vercel[bot]
Preview – blocknote — 867437f6 Deployed Nov 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants