Skip to content

Commit

Permalink
fix: make cursor center for different line height (#36586)
Browse files Browse the repository at this point in the history
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 #28012 (Problem with TextInput lineHeight on iOS)
This RP will fix the issue caused in
[PR](#36484)

Changelog:
[iOS][Added] - Fixed cursor height on multiline text input

Pull Request resolved: #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
  • Loading branch information
soumyajit4419 authored and facebook-github-bot committed Mar 23, 2023
1 parent a45d346 commit 987c6fd
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,12 @@ - (CGRect)caretRectForPosition:(UITextPosition *)position
return CGRectZero;
}

return [super caretRectForPosition:position];
CGRect rect = [super caretRectForPosition:position];
UIFont *font = self.font;
float prevHeight = rect.size.height;
rect.size.height = font.pointSize - font.descender;
rect.origin.y += (prevHeight - rect.size.height);
return rect;
}

#pragma mark - Utility Methods
Expand Down

0 comments on commit 987c6fd

Please sign in to comment.