Skip to content

fix(mobile): serialize a list the engine nested inside a paragraph (rich editor follow-up) - #22145

Merged
Jinwoo-H merged 1 commit into
mainfrom
ota-fu-webkit-bullet-list
Sep 22, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
ota-fu-webkit-bullet-list

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​121 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​117
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​51 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​49

A list the engine nested inside a paragraph survives the markdown round trip

Why

Pressing the bullet-list command on a paragraph makes both engines nest the <ul> inside the <p> rather than replace it (captured through the render rig, Chromium 147 and WebKit 26.4; WebKit additionally wraps the item text in a styled span with a trailing break). The serializer read the paragraph's text and walked past the list, so a bullet list did not survive a markdown round trip: - alpha came back as alpha. Numbered lists nest the same way, and leaving the list with two returns and typing yields <p><ul><li>solo</li></ul><div>after the list</div></p>, which read as soloafter the list. Found by C2's render check on 2026-09-21; recorded as WebKit-only, measured here as both.

What

blockMarkdown in mobile/src/components/rich-markdown/html-block-markdown.ts dispatches a paragraph that carries a list to blocksAroundLists, which walks the children and emits a paragraph for each run of inline content and a list for each <ul>/<ol>, joined as blocks, recursing into an element child that itself holds such a list. The ownership question sits beside its mirror in html-list-markdown.ts as holdsUnownedList: a list whose closest('li') is null is a block wherever it sits; a list an item owns is left to listMarkdown. Task lists and nested lists are untouched. No user-agent branch, no DOM normalisation, no type assertion. The parse side needs no mirror: - x already renders as a top-level <ul>, the shape the fixed serializer reports, pinned by the flat control.

Red before, green after

case red assertion
bullet list nested in a paragraph expected 'alpha\nbeta' to be '- alpha\n- beta'
numbered list nested in a paragraph expected 'first\nsecond' to be '1. first\n2. second'
list with text around it expected 'before the listsoloafter the list' to be 'before the list\n\n- solo\n\nafter the list'
render check, Chromium and WebKit expected 'bullet round trip' to be '- bullet round trip'

Each unit case asserts ul.parentElement.tagName === 'P' before reading, and the render case asserts the same nesting as a precondition, so if an engine ever stops nesting the case fails rather than passing vacuously. Trap recorded in the test: editor.innerHTML = '<p><ul>…' never builds the nested shape, because the HTML parser closes the <p>; the fixture sets the paragraph's own innerHTML.

Verification

Lane on 99aeeb391e: round-trip test 13 passed, render check 18 passed, full mobile suite 808 files, config/scripts 251 files, tsc, ratchet, lints, anti-slop, changed-code quality all 0. Lead gate against b9643365ba: all gates 0; config/scripts 251 files passed; mobile 808 files passed; no machine paths.

`insertUnorderedList` puts the `<ul>` inside the `<p>` it was given rather than replacing it —
measured on WebKit 26.4 and Chromium 147 both — and `blockMarkdown` read such a paragraph inline.
A bullet list the user typed came back as the paragraph's own text with no marker, so it did not
survive a markdown round trip, on the page and in the native WebView alike.

The serializer now reads structure wherever the list sits: text before it is a paragraph, the list
is a list, text after is a paragraph. The DOM is left as the engine made it and no branch asks
which engine is running. The parse side needs no mirror — it already renders `- x` as a top-level
`<ul>`, which is the shape the fixed serializer reports, and the flat control case pins that.

The unit fixture is built through the paragraph's own `innerHTML`: the HTML parser closes a `<p>`
before a `<ul>`, so a markup string on the editor gives two siblings and would measure the flat
shape. Each case asserts the nesting it got before it reads anything.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 23bbe716-bf22-46fb-8884-d23a37a294ce

📥 Commits

Reviewing files that changed from the base of the PR and between b964336 and 99aeeb3.

📒 Files selected for processing (4)
  • config/scripts/mobile-web-app-rich-markdown-render.test.mjs
  • mobile/src/components/rich-markdown/html-block-markdown.ts
  • mobile/src/components/rich-markdown/html-list-markdown.ts
  • mobile/src/components/rich-markdown/markdown-round-trip.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The serializer now detects unordered and ordered lists nested inside paragraphs or divs. It separates surrounding inline text into Markdown blocks and serializes the lists independently. New round-trip tests cover bullet lists, numbered lists, and surrounding text. Browser tests verify Chromium and WebKit behavior, Markdown reloads, and the absence of CSP violations and console errors.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 99aee

Nested lists now serialize as separate Markdown blocks while preserving surrounding text, with regression coverage for affected browser behavior. The change is ready to merge with normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem, implementation, scope, and verification results, but it omits several required template sections. It has no linked issue, visual proof or N/A statement, Testing s… Add the missing required sections. Include a linked issue after “Fixes #”, attach visual proof or write N/A with a reason, complete the Testing checkboxes and platform details, and complete the Review, Agent skill upstream boundary, Notes, …
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the mobile serialization fix for lists nested inside paragraphs. It is specific and reflects the main change.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 4 files.
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: Description check

Explanation

The description explains the problem, implementation, scope, and verification results, but it omits several required template sections. It has no linked issue, visual proof or N/A statement, Testing section with required checkboxes, Review section, boundary declaration, Notes, or Checklist.

Resolution

Add the missing required sections. Include a linked issue after “Fixes #”, attach visual proof or write N/A with a reason, complete the Testing checkboxes and platform details, and complete the Review, Agent skill upstream boundary, Notes, and Checklist sections.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

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

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — serializer fix for a contenteditable engine nesting a list inside a paragraph, plus its unit and render coverage.

  • blocksAroundLists dispatch for list-bearing paragraphs — blockMarkdown's p/div branch now emits the paragraph's real blocks (inline runs and each <ul>/<ol>) instead of reading the paragraph inline and walking past the list.
  • holdsUnownedList ownership rule — a list whose closest('li') is null is a block wherever it sits, the mirror of directNestedLists; lists owned by an item are still serialized by listMarkdown.
  • Round-trip unit cases — bullet/ordered list nested in a <p> (including WebKit's span + trailing <br> item) and text-list-text, each asserting the P nesting precondition and a flat-shape control.
  • Real-browser render case — presses Bullet list, asserts the engine nested the <ul> in the <p>, asserts the reported change is - bullet round trip, then re-renders that markdown and waits for the flat list markup.

I verified the new unit cases are genuine guards: restoring the old inline dispatch makes exactly those 3 fail (3 failed | 10 passed), and the full rich-markdown directory passes (10 files / 88 tests). check:code-quality:changed reports 0 new findings. The ownership rule is consistent with listItemText/directNestedLists for lists nested inside a list item's <p>, and task lists are untouched.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit 35897da into main Sep 22, 2026
59 of 61 checks passed
@Jinwoo-H
Jinwoo-H deleted the ota-fu-webkit-bullet-list branch September 22, 2026 05:11
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.

1 participant