Skip to content

iOS: async rendering causes content clipping in onLayout-based containers #824

Description

@hryhoriiK97

Summary

When EnrichedMarkdownText is used inside any container that measures content height via onLayout, long markdown content gets clipped on iOS. The last paragraph is cut off or only appears when the user scrolls. The issue does not reproduce on Android.

Confirmed with @gorhom/bottom-sheet (v5), but affects any component that sizes itself based on onLayout measurements — bottom sheets, modal sheets, collapsible panels, auto-sizing wrappers, etc.

The problem

Containers that measure content height via onLayout get an incomplete measurement because the native markdown view has not finished rendering when the first onLayout fires.

With the native rendering pipeline, applyRenderedText() is posted to the main thread after parsing completes on a background thread. This means:

  1. The container's onLayout fires when the wrapping view first reports its height
  2. At that point, the native markdown view hasn't finished rendering all paragraphs yet
  3. The container snaps/sizes to this incomplete height
  4. Trailing content is cut off — only visible if the user scrolls

Workaround

Remounting the container (via a React key change) forces a fresh measure cycle after the markdown has fully rendered. This works but is wasteful and causes a visible flash/flicker.

Expected behavior

The native view should trigger a layout invalidation after applyRenderedText() completes, so parent containers can re-measure with the final content height without requiring a full remount.

Environment

  • Library version: 1.0.2
  • React Native: 0.83.6 (Fabric / New Architecture)
  • Confirmed with: @gorhom/bottom-sheet ^5.2.8 (but not specific to it)
  • Platform: iOS only (not reproducible on Android)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions