Uh oh!
There was an error while loading. Please reload this page.
feat: [iOS] add caretHeight and caretYoffset to TextInput component - #37147
feat: [iOS] add caretHeight and caretYoffset to TextInput component#37147OlimpiaZurek wants to merge 6 commits into
Conversation
facebook-github-bot
commented
Apr 28, 2023
Hi @OlimpiaZurek! 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: 12f2c3c |
facebook-github-bot
commented
Apr 28, 2023
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
fabioh8010
left a comment
There was a problem hiding this comment.
Hey @OlimpiaZurek ! I reviewed your code and left some comments, minor things I just noticed. Besides that, I have two other points:
- Please include a Test Plan in your PR. For example, you could attach a video showing you how your props works in the text input for iOS.
- Also create a PR to include your props in the react-native-website repo. You can link each issue to the other to keep track of the overall progress.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
e265c13 to
2cbd5a3CompareOlimpiaZurek
commented
May 12, 2023
All comments have already been resolved. Can someone take another look and review? Thanks! |
caefbb8 to
5e48d26Comparekoko57
commented
Jun 16, 2023
Conflicts resolved, ready for review |
sakluger
commented
Jan 16, 2024
Hey @fabioh8010 - would it be possible to add this PR to your list of priorities? It's one of our oldest outstanding bugs and we'd love to get it resolved. Thanks! |
fabioh8010
commented
Jan 17, 2024
Hi @sakluger , I don't work at Meta, I just reviewed because I'm from the same company of the PR author. |
cpojer
commented
Jan 30, 2024
@sammy-SC@yungsters could you merge this? |
There was a problem hiding this comment.
why are there two underscores before member variables?
There was a problem hiding this comment.
I used double underscores to avoid name collisions. Changed implementation a bit and removed them.
There was a problem hiding this comment.
what if only _caretYOffset is set? Shouldn't the below block be executed?
There was a problem hiding this comment.
The block should only be executed if both properties are set.
There was a problem hiding this comment.
why is this override needed? I don't understand what it is trying to achieve on top of handling _caretYOffset and _caretHeight in the method caretRectForPosition above.
There was a problem hiding this comment.
The goal is to avoid the cursor touching the the symbols of the previous line in the second and subsequent lines:
This is the default behavior derived from caretRectForPosition. To fix this, I added two new properties _caretYOffset and _caretHeight to calculate the caret position and caret height, thus preventing the cursor from overlapping the previous line of text.
To keep the same effect on selection selectionRectsForRange needs to be override as well.
There was a problem hiding this comment.
Can you add a screenshot of what this looks like with a multi-line text selection?
bd5c769 to
f55a9ffCompareOlimpiaZurek
commented
Mar 27, 2024
@sammy-SC All comments have been resolved. Can you take a look and review ? Thanks! |
javache
commented
Apr 2, 2024
LGTM, few comments. |
| return originalRect; | ||
| } | ||
| - (NSArray *)selectionRectsForRange:(UITextRange *)range { |
There was a problem hiding this comment.
| - (NSArray *)selectionRectsForRange:(UITextRange *)range { | |
| - (NSArray<UITextSelectionRect *> *)selectionRectsForRange:(UITextRange *)range { |
| #import <React/RCTTextAttributes.h> | ||
| //the UITextSelectionRect subclass needs to be created because the original version is not writable | ||
| @interface CustomTextSelectionRect : UITextSelectionRect |
There was a problem hiding this comment.
UITextSelectionRect is explicitly documented as being an abstract base class so this makes sense. Maybe mention that instead of it not being writable?
Use RCT as prefix
| @interfaceCustomTextSelectionRect : UITextSelectionRect | |
| @interfaceRCTTextSelectionRect : UITextSelectionRect |
There was a problem hiding this comment.
Can you add a screenshot of what this looks like with a multi-line text selection?
| - (NSArray *)selectionRectsForRange:(UITextRange *)range { | ||
| NSArray *superRects = [super selectionRectsForRange:range]; | ||
| if(_caretYOffset != 0 && _caretHeight != 0) { |
There was a problem hiding this comment.
Should this be ||, so this works if you specify either one of the properties?
There was a problem hiding this comment.
The block should only be executed if both properties are set.
| for (UITextSelectionRect *rect in superRects) { | ||
| CustomTextSelectionRect *customTextRect = [[CustomTextSelectionRect alloc] init]; | ||
| customTextRect.rect = CGRectMake(rect.rect.origin.x, rect.rect.origin.y + _caretYOffset, rect.rect.size.width, _caretHeight); |
There was a problem hiding this comment.
This then needs to handle _caretHeight being potentially 0.
There was a problem hiding this comment.
The block should only be executed if both properties are set.
react-native-bot
commented
Oct 3, 2024
This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
react-native-bot
commented
Oct 10, 2024
This PR was closed because it has been stalled for 7 days with no activity. |

Summary:
This PR adds support for the caret height and caret position properties in iOS multi-line TextInput
PR for the docs update: react/react-native-website#3709
Changelog:
[IOS] [ADDED] - Add
caretHeightandcaretYOffsetprops to TextInput componentTest Plan:
Default caret:
default_caret.mov
Caret with
caretHeightandcaretYOffsetadjustment:adjusting_caret.mov