From c24d41a60d787439660a3be3cd8a6b77b2b5e88b Mon Sep 17 00:00:00 2001 From: Jakub Kasprzyk Date: Tue, 17 Nov 2026 15:54:50 +0100 Subject: [PATCH] Lay out multiline TextInput lines without the font's leading on iOS React Native measures text with NSLayoutManager.usesFontLeading set to NO (since #27195), so a multiline TextInput is sized for lines of ascender + descender. RCTUITextView kept UIKit's default and laid its lines out with the font's leading on top. For a font with leading, the text then didn't fit the measured view: with Hiragino Sans at 16 pt each line took 24 pt instead of 16 pt, the view scrolled, its first line was cut off and the selection highlight was a line and a half tall. An explicit lineHeight didn't prevent it. Turn the font's leading off in RCTUITextView too, on its NSTextLayoutManager, or on its NSLayoutManager where UIKit uses TextKit 1. Fonts without leading, such as the system font, lay out as before. --- .../Text/TextInput/Multiline/RCTUITextView.mm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.mm b/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.mm index eef87f87f632..4b5182d217ea 100644 --- a/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.mm +++ b/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.mm @@ -58,6 +58,16 @@ - (instancetype)initWithFrame:(CGRect)frame self.textColor = [UIColor blackColor]; // This line actually removes 5pt (default value) left and right padding in UITextView. self.textContainer.lineFragmentPadding = 0; + // Lay out lines without the font's leading, as `RCTTextLayoutManager` measures them. + if (@available(iOS 16.0, *)) { + if (self.textLayoutManager != nil) { + self.textLayoutManager.usesFontLeading = NO; + } else { + self.layoutManager.usesFontLeading = NO; + } + } else { + self.layoutManager.usesFontLeading = NO; + } #if !TARGET_OS_TV self.scrollsToTop = NO; #endif