Repository navigation
Conversation
|
@jasozh has exported this pull request. If you are a Meta employee, you can view the originating Diff in D127932169. |
) Summary: Fixes an issue where inline views in text on iOS are not properly positioned from their actual baseline, resulting in situations where the view/image appears lower than expected or with less padding from the previous line. ### Root Cause After TextKit lays out the text, RCTTextLayoutManager tries to position an inline view's frame on the baseline. It does so by using `glyphRect.origin.y + glyphRect.size.height` to calculate the line bottom, then adding `font.descender` to derive the baseline. However, this fails in two cases. First, when a line only contains an attachment, the baseline should be the line bottom, but the current formula still adds `font.descender` which positions the view too high and clips into the previous line. Second, when `lineHeight` is set, text is lifted by an `NSBaselineOffset` to center it. The current formula fails to account for this offset, so inline views appear placed below the actual text baseline. ### This PR Modify RCTTextLayoutManager so that instead of manually computing the baseline, we ask TextKit for the baseline used on that line. Changelog: [iOS][Fixed] - Fix inline views on iOS being misaligned from the baseline Reviewed By: vzaidman Differential Revision: D127932169
jasozh
force-pushed
the
export-D127932169
branch
from
November 19, 2026 22:12
2827a45 to
f0a51cb
Compare
Visual regressionNo visual differences at android: no capture |
This branch has not been deployed
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:
Fixes an issue where inline views in text on iOS are not properly positioned from their actual baseline, resulting in situations where the view/image appears lower than expected or with less padding from the previous line.
Root Cause
After TextKit lays out the text, RCTTextLayoutManager tries to position an inline view's frame on the baseline. It does so by using
glyphRect.origin.y + glyphRect.size.heightto calculate the line bottom, then addingfont.descenderto derive the baseline. However, this fails in two cases. First, when a line only contains an attachment, the baseline should be the line bottom, but the current formula still addsfont.descenderwhich positions the view too high and clips into the previous line. Second, whenlineHeightis set, text is lifted by anNSBaselineOffsetto center it. The current formula fails to account for this offset, so inline views appear placed below the actual text baseline.This PR
Modify RCTTextLayoutManager so that instead of manually computing the baseline, we ask TextKit for the baseline used on that line.
Changelog: [iOS][Fixed] - Fix inline views on iOS being misaligned from the baseline
Reviewed By: vzaidman
Differential Revision: D127932169