Skip to content

Commit 987c6fd

Browse files
soumyajit4419facebook-github-bot
authored andcommitted
fix: make cursor center for different line height (facebook#36586)
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 facebook#28012 (Problem with TextInput lineHeight on iOS) This RP will fix the issue caused in [PR](facebook#36484) Changelog: [iOS][Added] - Fixed cursor height on multiline text input Pull Request resolved: facebook#36586 Test Plan: Tested for different cursor height https://user-images.githubusercontent.com/46092576/227004355-3886a0b5-7cdb-4fdc-a16b-3c4abb729737.mov https://user-images.githubusercontent.com/46092576/227004361-48099f81-9f52-460d-8ae8-d0ddb09dc47d.mov Reviewed By: javache Differential Revision: D44307457 Pulled By: genkikondo fbshipit-source-id: afeea5605ed8557cdeec1e62324c85665ce367d6
1 parent a45d346 commit 987c6fd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,12 @@ - (CGRect)caretRectForPosition:(UITextPosition *)position
298298
return CGRectZero;
299299
}
300300

301-
return [super caretRectForPosition:position];
301+
CGRect rect = [super caretRectForPosition:position];
302+
UIFont *font = self.font;
303+
float prevHeight = rect.size.height;
304+
rect.size.height = font.pointSize - font.descender;
305+
rect.origin.y += (prevHeight - rect.size.height);
306+
return rect;
302307
}
303308

304309
#pragma mark - Utility Methods

0 commit comments

Comments
 (0)