-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[iOS] reduce cursor size for multiline(TextInput) #36484
Conversation
Hi @soumyajit4419! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Base commit: 221aacd |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
@dmytrorykun has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
The height manipulation and Y offset seem like arbitrary numbers. Is there any source for why these numbers are correct/the most appropriates solution here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caret sizing should be based on the font metrics, 0.75x or offsetting by 4 is not safe for all fonts.
return [super caretRectForPosition:position]; | ||
CGRect originalRect = [super caretRectForPosition:position]; | ||
originalRect.size.height *= 0.75; | ||
return CGRectMake(originalRect.origin.x, originalRect.origin.y + 4 , originalRect.size.width, originalRect.size.height); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes that originalRect's height < 4, so we can offset it by this much, which is not safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay .
Got it.
@javache I have updated my PR based on the comments |
packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.m
Outdated
Show resolved
Hide resolved
…TextView.m Co-authored-by: Pieter De Baets <pieter.debaets@gmail.com>
@javache has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
This PR shouldn't be merged at all. It causes bigger issue. It doesn't completely fix cursor issue on iOS multiline TextInput. Before: before.mp4After: after.mp4The ideal solution should be to align center both cursor and text, same as Text component. |
@situchan Thanks for the report, can you share a code-sample for it? I'll revert this change for now. @soumyajit4419: can you revisit this PR and include @situchan's test case? |
This pull request has been reverted by 8313f23. |
@javache this code should be enough for test. Just return in root App.js
|
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
@soumyajit4419 do you think the issue was fixed completely? Still has issues:
bug.mp4 |
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) ## Changelog [IOS] [ADDED] - Fixed cursor height on multiline text input <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> Pull Request resolved: facebook#36484 Test Plan: UI Before the change <img width="379" alt="Screenshot 2023-03-15 at 10 16 07 PM" src="https://user-images.githubusercontent.com/46092576/225380938-23b9b8a4-4b8a-45e1-bbf1-4af8ac8d9183.png"> UI After the change <img width="509" alt="Screenshot 2023-03-14 at 1 57 27 AM" src="https://user-images.githubusercontent.com/46092576/225380930-77ca853c-fae5-4bfa-82cf-03b2e22bf8da.png"> Reviewed By: dmytrorykun Differential Revision: D44130814 Pulled By: javache fbshipit-source-id: 09d53ecee6812e9a875dc5364bd91b76cc2bc1f5
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
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) ## Changelog [IOS] [ADDED] - Fixed cursor height on multiline text input <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> Pull Request resolved: facebook#36484 Test Plan: UI Before the change <img width="379" alt="Screenshot 2023-03-15 at 10 16 07 PM" src="https://user-images.githubusercontent.com/46092576/225380938-23b9b8a4-4b8a-45e1-bbf1-4af8ac8d9183.png"> UI After the change <img width="509" alt="Screenshot 2023-03-14 at 1 57 27 AM" src="https://user-images.githubusercontent.com/46092576/225380930-77ca853c-fae5-4bfa-82cf-03b2e22bf8da.png"> Reviewed By: dmytrorykun Differential Revision: D44130814 Pulled By: javache fbshipit-source-id: 09d53ecee6812e9a875dc5364bd91b76cc2bc1f5
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
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)
Changelog
[IOS] [ADDED] - Fixed cursor height on multiline text input
Test Plan
UI Before the change
UI After the change