fix(ios): include all layout-affecting props in measurement cache key#494
Open
hryhoriiK97 wants to merge 1 commit into
Open
fix(ios): include all layout-affecting props in measurement cache key#494hryhoriiK97 wants to merge 1 commit into
hryhoriiK97 wants to merge 1 commit into
Conversation
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>
There was a problem hiding this comment.
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
MeasurementCacheKeyto includelineBreakStrategyIOS,writingDirection, andspoilerOverlay. - Update
MeasurementCacheKeyequality 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.
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, |
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.
Summary
lineBreakStrategyIOS,writingDirection, andspoilerOverlaytoMeasurementCacheKey— including the struct fields, equality operator, hash function, andbuildMeasurementCacheKeybuilderTest plan
EnrichedMarkdownTextcomponents with the same markdown but differentwritingDirectionvalues get independently measured heightsMade with Cursor