diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.kt index d9c28ca5fa2..5c0840a0ab4 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.kt @@ -877,13 +877,22 @@ internal object TextLayoutManager { ) } - val desiredWidth = ceil(Layout.getDesiredWidth(text, paint)).toInt() - + // Layout.getDesiredWidth is a full measuring pass over the text, so only run it when its + // result can affect the layout width. It cannot when the width is EXACTLY, nor when the text + // was boring but did not fit: boring.width is the unwrapped width of the same text and we only + // get here if it exceeds floor(width), so min(desiredWidth, floor(width)) is floor(width). val layoutWidth = - when (widthYogaMeasureMode) { - YogaMeasureMode.EXACTLY -> ceil(width).toInt() - YogaMeasureMode.AT_MOST -> min(desiredWidth, floor(width).toInt()) - else -> desiredWidth + when { + widthYogaMeasureMode == YogaMeasureMode.EXACTLY -> ceil(width).toInt() + widthYogaMeasureMode == YogaMeasureMode.AT_MOST && boring != null -> floor(width).toInt() + else -> { + val desiredWidth = ceil(Layout.getDesiredWidth(text, paint)).toInt() + if (widthYogaMeasureMode == YogaMeasureMode.AT_MOST) { + min(desiredWidth, floor(width).toInt()) + } else { + desiredWidth + } + } } val enableStartOverhang = widthYogaMeasureMode == YogaMeasureMode.EXACTLY val layout =