Skip to content

fix(android): measure spacer lines inside lists as tall as they are drawn - #1102

Merged
jnowakow merged 1 commit into
mainfrom
fix/android-list-line-height-priority
Oct 30, 2026
Merged

jnowakow merged 1 commit into
mainfrom
fix/android-list-line-height-priority

Conversation

@jnowakow

@jnowakow jnowakow commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

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.

- First item
  > A quote inside the item

  Text after the quote.
- Second item
  > A quote inside the item

  Text after the quote.
- Third item
  > A quote inside the item

  Text after the quote.
- Fourth item
  > A quote inside the item

  Text after the quote.
- The last line should be fully visible.
Before After
Before After

PR Checklist

  • Code compiles and runs on iOS
  • Code compiles and runs on Android
  • Updated documentation/README if applicable
  • Ran example app to verify changes
  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

…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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 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

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.

[Android] Spacer lines are measured shorter than they are drawn, so the last line overflows the view

3 participants