From e1885853ac46f4e84af9e4a50203d50b773f1a27 Mon Sep 17 00:00:00 2001 From: Soumyajit Behera Date: Wed, 22 Mar 2023 05:32:09 -0700 Subject: [PATCH] reduce cursor size for multiline(TextInput) (#36484) Summary: Currently in multiline input the cursor touches the previous line. So this reduces its height sets its position so that I does not touch previous line. This PR will also fix the issue https://github.com/facebook/react-native/issues/28012 (Problem with TextInput lineHeight on iOS) ## Changelog [IOS] [ADDED] - Fixed cursor height on multiline text input Pull Request resolved: https://github.com/facebook/react-native/pull/36484 Test Plan: UI Before the change Screenshot 2023-03-15 at 10 16 07 PM UI After the change Screenshot 2023-03-14 at 1 57 27 AM Reviewed By: dmytrorykun Differential Revision: D44130814 Pulled By: javache fbshipit-source-id: 09d53ecee6812e9a875dc5364bd91b76cc2bc1f5 --- .../Libraries/Text/TextInput/Multiline/RCTUITextView.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.m b/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.m index 5d5d3085879ba2..21cadf2c89f770 100644 --- a/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.m +++ b/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.m @@ -298,7 +298,11 @@ - (CGRect)caretRectForPosition:(UITextPosition *)position return CGRectZero; } - return [super caretRectForPosition:position]; + CGRect rect = [super caretRectForPosition:position]; + UIFont *font = self.font; + rect.size.height = font.pointSize - font.descender; + rect.origin.y -= font.descender; + return rect; } #pragma mark - Utility Methods