Skip to content

fix(ios): include all layout-affecting props in measurement cache key#494

Open
hryhoriiK97 wants to merge 1 commit into
mainfrom
fix/ios-cache-key-completeness
Open

fix(ios): include all layout-affecting props in measurement cache key#494
hryhoriiK97 wants to merge 1 commit into
mainfrom
fix/ios-cache-key-completeness

Conversation

@hryhoriiK97

Copy link
Copy Markdown
Collaborator

Summary

  • Adds lineBreakStrategyIOS, writingDirection, and spoilerOverlay to MeasurementCacheKey — including the struct fields, equality operator, hash function, and buildMeasurementCacheKey builder
  • Prevents stale cached measurement sizes when these layout-affecting props differ between components (e.g. RTL vs LTR text, different line-break strategies)

Test plan

  • Verify two EnrichedMarkdownText components with the same markdown but different writingDirection values get independently measured heights
  • Verify cache still hits correctly when all props are identical across re-renders
  • Run existing tests to confirm no regressions

Made with Cursor

The measurement cache key omitted lineBreakStrategyIOS, writingDirection,
and spoilerOverlay. Two components with the same markdown but different
values for these props could share a cached measurement, returning an
incorrect height — particularly visible with RTL text or different
line-break strategies.

Co-authored-by: Cursor <cursoragent@cursor.com>

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.

Pull request overview

This PR updates the iOS measurement cache key for react-native-enriched-markdown so cached text measurements are invalidated when additional layout-affecting props change, preventing reuse of stale sizes across components that render the same markdown with different layout behavior.

Changes:

  • Extend MeasurementCacheKey to include lineBreakStrategyIOS, writingDirection, and spoilerOverlay.
  • Update MeasurementCacheKey equality and hashing to account for the new fields.
  • Update buildMeasurementCacheKey(...) to populate the new fields from component props.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.

Comment on lines 45 to +48
MarkdownFlavor flavor;
std::string lineBreakStrategyIOS;
std::string writingDirection;
std::string spoilerOverlay;
Comment on lines 52 to 56
return std::tie(markdown, maxWidth, allowTrailingMargin, allowFontScaling, maxFontSizeMultiplier,
md4cFlagsUnderline, md4cFlagsSuperscript, md4cFlagsSubscript, md4cFlagsHighlight,
md4cFlagsLatexMath, styleFingerprint, fontScale, flavor) ==
md4cFlagsLatexMath, styleFingerprint, fontScale, flavor, lineBreakStrategyIOS, writingDirection,
spoilerOverlay) ==
std::tie(other.markdown, other.maxWidth, other.allowTrailingMargin, other.allowFontScaling,
Comment on lines +81 to +83
HashUtils::hash_one(h, key.lineBreakStrategyIOS);
HashUtils::hash_one(h, key.writingDirection);
HashUtils::hash_one(h, key.spoilerOverlay);
Comment on lines +165 to +167
.lineBreakStrategyIOS = props.lineBreakStrategyIOS,
.writingDirection = props.writingDirection,
.spoilerOverlay = props.spoilerOverlay,
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.

2 participants