Skip to content

fix(mdxish): space callouts under tight list items - #1671

Merged
DamaraNadhra merged 3 commits into
nextfrom
damara/callout-list-spacing
Nov 8, 2026
Merged

DamaraNadhra merged 3 commits into
nextfrom
damara/callout-list-spacing

Conversation

@DamaraNadhra

@DamaraNadhra DamaraNadhra commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor
🎫 Resolve CX-4214

🎯 What does this PR do?

Problem

a callout (or code block, image) under a tight list item sits flush against the item text in view mode, while the editor spaces it

Root Cause

mdast-util-to-hast unwraps a tight list item's text from <p>, and block spacing comes from the paragraph margin, so the callout after it gets no gap. the editor always wraps item text in <p>

Fix

listItemHandler renders a tight item as loose when its text is followed by a block other than a sublist, so the text gets a <p> like in the editor. plain items and text followed only by a sublist stay tight

while QAing this i also noticed plain tight list items look more spaced out in the editor than in view mode, same root cause (the editor always wraps item text in <p>), so i opened readmeio/readme#22253 to fix that side too, they can ship in either order

🧪 QA tips

  • render 1. one\n2. text\n > 📘\n > body, the second <li> should be <p>text</p> + the callout and the first still bare text
  • - text\n - nested stays unwrapped
  • npx vitest run __tests__/lib/mdxish

📸 Screenshot or Loom

Before After
view-callout-list-before view-callout-list-after

blast radius QA

rendered every list shape i could think of through mdxish() with the old and new listItemHandler and screenshotted each one in the example app, 🟡 = render changed, ✅ = before and after are byte-identical screenshots (and identical HTML)

🟡 changed (12), tight item with text followed by a block, now spaced like a loose item
scenarioBeforeAfter
🟡 changed
tight, text + callout
A1-before A1-after
🟡 changed
tight, text + code block
A2-before A2-after
🟡 changed
tight, text + table
A3b-before A3b-after
🟡 changed
tight, text + plain blockquote
A4-before A4-after
🟡 changed
tight, text + html block
A5-before A5-after
🟡 changed
tight, text + JSX Callout
A6-before A6-after
🟡 changed
tight, text + magic block image
A7-before A7-after
🟡 changed
ordered, text + callout
A8-before A8-after
🟡 changed
task list, text + code
A9-before A9-after
🟡 changed
text + heading
A10-before A10-after
🟡 changed
text + thematic break
A11-before A11-after
🟡 changed
text + sublist + callout
A12-before A12-after
✅ unchanged (15)
scenarioBeforeAfter
✅ same
text + table after a blank line
A3-before A3-after
✅ same
callout before text
A13-before A13-after
✅ same
plain tight list
B1-before B1-after
✅ same
tight + nested list only
B2-before B2-after
✅ same
loose list + callout
B3-before B3-after
✅ same
text + HTML comment
B4-before B4-after
✅ same
text + link definition
B5-before B5-after
✅ same
text + JSX comment
B10-before B10-after
✅ same
text + inline image only
B11-before B11-after
✅ same
multi-paragraph item
B12-before B12-after
✅ same
table cell list-ish text
B13-before B13-after

@DamaraNadhra DamaraNadhra added the anand-review Attach to trigger the anand-review AI reviewer (COMMENT review; label removed when the run ends) label Nov 3, 2026
@github-actions github-actions Bot removed the anand-review Attach to trigger the anand-review AI reviewer (COMMENT review; label removed when the run ends) label Nov 3, 2026
@greptile-apps

greptile-apps Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The incremental changes appear safe to merge.

Reviews (2) · Last reviewed commit: "fix: ignore hidden nodes when deciding t..." · Reviewed by Greptile

Comment thread processor/plugin/mdxish-handlers.ts Resolved
greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 3, 2026
Comment thread processor/plugin/mdxish-handlers.ts Resolved

@eaglethrost eaglethrost 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.

Approach is sound but the blast radius of this is quite big, there's a lot of spacing changes like in task lists as well:

Image

Is this expected? Are other component spacing also expected to change? Personally I feel the task item spacing is too big & don't think it matches the editor.

Might be good to try to contain this to components in lists. I think this also related to the RM-18969 work since it's hard to track how the styling changes here relate to the editor

Comment thread processor/plugin/mdxish-handlers.ts Resolved
Comment thread processor/plugin/mdxish-handlers.ts Resolved
@chrisschnaars

Copy link
Copy Markdown
Contributor

there's a lot of spacing changes like in task lists as well:

fwiw I think the spacing in a task list looks good too

@greptile-apps
greptile-apps Bot dismissed their stale review November 6, 2026 02:54

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@DamaraNadhra
DamaraNadhra merged commit f21e0d8 into next Nov 8, 2026
8 checks passed
@DamaraNadhra
DamaraNadhra deleted the damara/callout-list-spacing branch November 8, 2026 23:12
rafegoldberg pushed a commit that referenced this pull request Nov 9, 2026
## Version 16.2.1
### 🛠 Fixes & Updates

* address flagged CodeQL alerts ([#1682](#1682)) ([3b14a86](3b14a86))
* move lint and format to oxlint and oxfmt ([#1680](#1680)) ([85c915b](85c915b))
* **deps:** patch Dependabot security vulnerabilities ([#1679](#1679)) ([bfc9c1b](bfc9c1b))
* pulling dependabot updates back a bit ([a9906c3](a9906c3))
* **mdxish:** space callouts under tight list items ([#1671](#1671)) ([f21e0d8](f21e0d8))
* **table:** stop centering unaligned headers ([#1670](#1670)) ([139d238](139d238))
* **deps-dev:** upgrade vitest to v5 ([#1681](#1681)) ([0946e08](0946e08))

<!--SKIP CI-->
@rafegoldberg

Copy link
Copy Markdown
Collaborator

This PR was released!

🚀 Changes included in v16.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants