Skip to content

Commit 0da2607

Browse files
committed
commit before change branch
1 parent 00c318c commit 0da2607

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,9 @@ public static long measureText(
512512
// incorrect
513513
// values when the paragraph is RTL and `setSingleLine(true)`.
514514
? calculatedWidth - lineWidth
515-
: layout.getLineRight(line) - placeholderWidth;
515+
// add a check that text is single line (not only 1 line, but forced to
516+
// singleline)
517+
: layout.getEllipsizedWidth() - placeholderWidth;
516518
} else {
517519
// The direction of the paragraph may not be exactly the direction the string is
518520
// heading
@@ -544,7 +546,13 @@ public static long measureText(
544546
}
545547
}
546548
// Vertically align the inline view to the baseline of the line of text.
547-
float placeholderTopPosition = layout.getLineBaseline(line) - placeholderHeight;
549+
float placeholderTopPosition;
550+
if (calculatedLineCount == 1) {
551+
// you need to check that text is actually single line and not only rendering on 1 line
552+
placeholderTopPosition = layout.getLineBaseline(0) - placeholderHeight;
553+
} else {
554+
placeholderTopPosition = layout.getLineBaseline(line) - placeholderHeight;
555+
}
548556
int attachmentPosition = attachmentIndex * 2;
549557

550558
// The attachment array returns the positions of each of the attachments as

0 commit comments

Comments
 (0)