Repository navigation
fix(mdxish): space callouts under tight list items - #1671
Conversation
[Low impact] The incremental changes appear safe to merge. Reviews (2) · Last reviewed commit: "fix: ignore hidden nodes when deciding t..." · Reviewed by Greptile |
eaglethrost
left a comment
There was a problem hiding this comment.
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:
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
fwiw I think the spacing in a task list looks good too |
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
## 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-->
This PR was released!🚀 Changes included in v16.2.1 |

🎯 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-hastunwraps 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
listItemHandlerrenders 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 tightwhile 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
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 - nestedstays unwrappednpx vitest run __tests__/lib/mdxish📸 Screenshot or Loom
blast radius QA
rendered every list shape i could think of through
mdxish()with the old and newlistItemHandlerand 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
tight, text + callout
tight, text + code block
tight, text + table
tight, text + plain blockquote
tight, text + html block
tight, text + JSX Callout
tight, text + magic block image
ordered, text + callout
task list, text + code
text + heading
text + thematic break
text + sublist + callout
✅ unchanged (15)
text + table after a blank line
callout before text
plain tight list
tight + nested list only
loose list + callout
text + HTML comment
text + link definition
text + JSX comment
text + inline image only
multi-paragraph item
table cell list-ish text