From bafd09d6347c57ba54dc3d50f2b7feeab3b81533 Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Thu, 2 Jul 2026 03:07:52 -0700 Subject: [PATCH 1/2] fix: reset cached style state in Fabric prepareForRecycle to stop stale-markdown flicker --- .../ios/EnrichedMarkdown.mm | 8 ++++++++ .../ios/EnrichedMarkdownText.mm | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/packages/react-native-enriched-markdown/ios/EnrichedMarkdown.mm b/packages/react-native-enriched-markdown/ios/EnrichedMarkdown.mm index 7ad95d7f6..fc6ccffcf 100644 --- a/packages/react-native-enriched-markdown/ios/EnrichedMarkdown.mm +++ b/packages/react-native-enriched-markdown/ios/EnrichedMarkdown.mm @@ -949,8 +949,16 @@ - (void)prepareForRecycle _cachedMarkdown = nil; _renderedMarkdown = nil; + _config = nil; + _md4cFlags = [ENRMMd4cFlags defaultFlags]; + _maxFontSizeMultiplier = 0; + _allowTrailingMargin = NO; _streamingAnimation = NO; _tableStreamingMode = ENRMTableStreamingModeProgressive; + _renderedStyleFingerprint = 0; + _pendingStyleFingerprint = 0; + _contextMenuItemTexts = nil; + _contextMenuItemIcons = nil; _dirtyFlags = ENRMDirtyNone; [super prepareForRecycle]; diff --git a/packages/react-native-enriched-markdown/ios/EnrichedMarkdownText.mm b/packages/react-native-enriched-markdown/ios/EnrichedMarkdownText.mm index 1dc109754..3b6ed82cd 100644 --- a/packages/react-native-enriched-markdown/ios/EnrichedMarkdownText.mm +++ b/packages/react-native-enriched-markdown/ios/EnrichedMarkdownText.mm @@ -639,10 +639,20 @@ - (void)prepareForRecycle _forceHeightUpdateOnNextRender = NO; _cachedMarkdown = nil; _renderedMarkdown = nil; + _config = nil; + _md4cFlags = [ENRMMd4cFlags defaultFlags]; + _maxFontSizeMultiplier = 0; + _lastElementMarginBottom = 0; + _allowTrailingMargin = NO; + _renderedStyleFingerprint = 0; + _pendingStyleFingerprint = 0; + _contextMenuItemTexts = nil; + _contextMenuItemIcons = nil; _accessibilityElements = nil; _accessibilityInfo = nil; _accessibilityNeedsRebuild = NO; [_spoilerManager removeAllOverlays]; + _spoilerManager = nil; if (_textView != nil) { ENRMSetAttributedText(_textView, [[NSAttributedString alloc] initWithString:@""]); _textView.hidden = YES; From 8fd2895fb77c0776d062213a6ad64f1e9a96a431 Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Thu, 2 Jul 2026 03:16:17 -0700 Subject: [PATCH 2/2] fix: reset md4c flags to prop baseline on recycle, not defaultFlags --- .../ios/EnrichedMarkdown.mm | 8 +++++++- .../ios/EnrichedMarkdownText.mm | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/react-native-enriched-markdown/ios/EnrichedMarkdown.mm b/packages/react-native-enriched-markdown/ios/EnrichedMarkdown.mm index fc6ccffcf..ae22bbc16 100644 --- a/packages/react-native-enriched-markdown/ios/EnrichedMarkdown.mm +++ b/packages/react-native-enriched-markdown/ios/EnrichedMarkdown.mm @@ -931,7 +931,8 @@ - (void)didMoveToWindow - (void)prepareForRecycle { - _props = std::make_shared(); + const auto resetProps = std::make_shared(); + _props = resetProps; [_renderCoordinator invalidate]; for (RCTUIView *segment in _segmentViews) { @@ -951,6 +952,11 @@ - (void)prepareForRecycle _renderedMarkdown = nil; _config = nil; _md4cFlags = [ENRMMd4cFlags defaultFlags]; + _md4cFlags.underline = resetProps->md4cFlags.underline; + _md4cFlags.superscript = resetProps->md4cFlags.superscript; + _md4cFlags.subscript = resetProps->md4cFlags.subscript; + _md4cFlags.latexMath = resetProps->md4cFlags.latexMath; + _md4cFlags.highlight = resetProps->md4cFlags.highlight; _maxFontSizeMultiplier = 0; _allowTrailingMargin = NO; _streamingAnimation = NO; diff --git a/packages/react-native-enriched-markdown/ios/EnrichedMarkdownText.mm b/packages/react-native-enriched-markdown/ios/EnrichedMarkdownText.mm index 3b6ed82cd..54f3ccd44 100644 --- a/packages/react-native-enriched-markdown/ios/EnrichedMarkdownText.mm +++ b/packages/react-native-enriched-markdown/ios/EnrichedMarkdownText.mm @@ -629,7 +629,8 @@ - (void)didMoveToWindow - (void)prepareForRecycle { - _props = std::make_shared(); + const auto resetProps = std::make_shared(); + _props = resetProps; [_renderCoordinator invalidate]; [_fadeAnimator cancel]; @@ -641,6 +642,11 @@ - (void)prepareForRecycle _renderedMarkdown = nil; _config = nil; _md4cFlags = [ENRMMd4cFlags defaultFlags]; + _md4cFlags.underline = resetProps->md4cFlags.underline; + _md4cFlags.superscript = resetProps->md4cFlags.superscript; + _md4cFlags.subscript = resetProps->md4cFlags.subscript; + _md4cFlags.latexMath = resetProps->md4cFlags.latexMath; + _md4cFlags.highlight = resetProps->md4cFlags.highlight; _maxFontSizeMultiplier = 0; _lastElementMarginBottom = 0; _allowTrailingMargin = NO;