Repository navigation
fix(android): measure spacer lines inside lists as tall as they are drawn - #1102
Merged
Merged
Conversation
…rawn The list applies its line height after its items have added their margin spacers. The shadow node measures the SpannableStringBuilder, which hands a line's LineHeightSpans to StaticLayout by start position, while the TextView draws a SpannableString copy, which hands them over in insertion order. So a spacer inside a list item was measured at its margin and drawn at the list's line height, and the last line was drawn below the measured bottom edge. Give the list's line-height span SPAN_FLAGS_LINE_HEIGHT_PRIORITY, as blockquotes already do, so it runs before the margin spans in both layouts. Fixes #1060
There was a problem hiding this comment.
🟢 Approval recommended
The localized fix follows existing span-priority handling, includes focused regression coverage, and has no identified blocking issues.
No open issues 🎉
What changed in this PR
Fixes Android spacer-height mismatches inside Markdown lists, preventing accumulated height differences from clipping the last line.
Changes:
- Gives list line-height spans priority so spacer margins determine their final height.
- Adds regression tests for measured-versus-drawn height and spacer dimensions.
- Extends test style configuration to support blockquote overrides.
| File | Description |
|---|---|
packages/react-native-enriched-markdown/android/src/test/java/com/swmansion/enriched/markdown/test/MarkdownRenderTestSupport.kt |
Supports custom blockquote styles in tests. |
packages/react-native-enriched-markdown/android/src/test/java/com/swmansion/enriched/markdown/ListSpacerLineHeightTest.kt |
Tests layout consistency and spacer heights within lists. |
packages/react-native-enriched-markdown/android/src/main/java/com/swmansion/enriched/markdown/renderer/ListRenderer.kt |
Applies priority ordering to list line-height spans. |
Review effort: Balanced
This was referenced Oct 27, 2026
jnowakow
marked this pull request as ready for review
October 27, 2026 10:24
maksg
approved these changes
Oct 30, 2026
This was referenced Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What/Why?
Fixes #1060. Alternative to #1062.
On Android, spacer lines inside a list item (a nested block's margin or padding) were measured at their margin but drawn at the list's line height, so the last line was clipped. The list adds its line-height span after the items' margin spans, and the measuring layout and the TextView apply those spans in a different order.
The list's line-height span now uses
SPAN_FLAGS_LINE_HEIGHT_PRIORITY, as blockquotes do, so it runs first in both. Spacers inside list items keep their own margin instead of stretching to the list's line height.Testing
Paste into the Playground (Set Raw Markdown) on Android. Before the fix, the last line is cut off at the bottom of the preview.
PR Checklist