-
Notifications
You must be signed in to change notification settings - Fork 20
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
[HOLD facebook/react-native#37465] Fix TextInput vertical alignment issue when using lineHeight prop on iOS (Paper - old arch) #57
Conversation
After the fix - Testing RNTester in Expensify/react-native
2023-05-23.09-25-28.mp4 |
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.
Code looks good, but I'd love to get a review from someone that's more familiar with this code and how it works
paragraphStyle.minimumLineHeight = lineHeight; | ||
paragraphStyle.maximumLineHeight = lineHeight; | ||
isParagraphStyleUsed = YES; | ||
// text with lineHeight lower then font.lineHeight does not correctly vertically align |
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.
Can you capitalize all comments and add a line break before them (except for the one after the if which is in a new level of indentation)?
// text with lineHeight lower then font.lineHeight does not correctly vertically align | |
// Text with lineHeight lower then font.lineHeight does not correctly vertically align |
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.
if (self.fragmentViewContainerBounds.size.height > 0) { | ||
// Apply custom bounds to fix iOS UITextField issue with lineHeight. | ||
// Sets the correct y coordinates for _UITextLayoutFragmentView. | ||
return UIEdgeInsetsInsetRect([super textRectForBounds:self.fragmentViewContainerBounds], borderAndPaddingInsets); | ||
} else { | ||
return UIEdgeInsetsInsetRect([super textRectForBounds:bounds], borderAndPaddingInsets); | ||
} |
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.
if (self.fragmentViewContainerBounds.size.height > 0) { | |
// Apply custom bounds to fix iOS UITextField issue with lineHeight. | |
// Sets the correct y coordinates for _UITextLayoutFragmentView. | |
return UIEdgeInsetsInsetRect([super textRectForBounds:self.fragmentViewContainerBounds], borderAndPaddingInsets); | |
} else { | |
return UIEdgeInsetsInsetRect([super textRectForBounds:bounds], borderAndPaddingInsets); | |
} | |
// Apply custom bounds to fix iOS UITextField issue with lineHeight. | |
// Sets the correct y coordinates for _UITextLayoutFragmentView. | |
return UIEdgeInsetsInsetRect([super textRectForBounds:self.fragmentViewContainerBounds.size.height > 0 ? self.fragmentViewContainerBounds : bounds], borderAndPaddingInsets); |
Can’t be simplified ?
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.
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.
LGTM
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.
Looks good to me. @fedirjh can you re-review when you get a chance please?
UIEdgeInsets borderAndPaddingInsets = UIEdgeInsetsMake(_textContainerInset.top, leftPadding, _textContainerInset.bottom, rightPadding); | ||
// The fragmentViewContainerBounds set the correct y coordinates for |
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.
Minor, so not a blocker
UIEdgeInsets borderAndPaddingInsets = UIEdgeInsetsMake(_textContainerInset.top, leftPadding, _textContainerInset.bottom, rightPadding); | |
// The fragmentViewContainerBounds set the correct y coordinates for | |
UIEdgeInsets borderAndPaddingInsets = UIEdgeInsetsMake(_textContainerInset.top, leftPadding, _textContainerInset.bottom, rightPadding); | |
// The fragmentViewContainerBounds set the correct y coordinates for |
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.
Thanks @cead22.
Adding a line-break before the comment
I believe you refer to
Can you capitalize all comments and add a line break before them (except for the one after the if which is in a new level of indentation)?
I added a line break before the comment with commit 3d12d11.
Github Website Issue
There was an issue with the GitHub (website), which would not update the PR Diff and commits. My remote branch fabriziobertoglio1987/text-input-vertical-alignment-expensify-2 included changes not available on Github Website PR.
CLICK TO OPEN VIDEO
2023-06-01.14-27-51.mp4
For this reason, I had to temporarily change the base branch.
Related Discussions: https://github.com/orgs/community/discussions/16351 isaacs/github#750 (comment)
I tested and reviewed the branch diff locally (git checkout text-input-vertical-alignment-expensify-2 && g diff ExpensifyRC1-0.72.0-alpha.0..
), and the branch has no issues.
Sorry. I remain available. Thanks
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.
LGTM and tests well
@cead22 which branch should we target ?
The base branch was changed.
|
Out of curiosity, why not merge into main? |
It looks like |
The main branch facebook/react-native changes every day. The facebook/react-native main branch sometimes has issues, for this reason, it is easier to use the release branch. |
Holding until the FB PR is approved and merged |
@fabriziobertoglio1987 any idea if/when the upstream PR will be merged? |
Thanks @cead22. The PR will be merged. I reached out via Discord to receive feedback on the PR. |
Thanks @cead22 This is the last update from Samuel Susla facebook#37465 (comment)
The was an issue with the internal facebook code linter (not open source). The PR will be merged soon. I remain available. |
Awesome, thanks for the update! |
cc @cead22 @fabriziobertoglio1987 The upstream PR was merged today 🎉 🎉 |
@fedirjh @j-piasecki can you re-review this please? I think we're ready to remove the hold, but to confirm, is this PR still targeting the right branch? |
This are the information I found:
|
@cead22 It looks like all commits since the last review are cosmetic or done simply to trigger CI, so should be good 🚀 |
Update 07/07
|
Update 08/07
|
Update 11/07
|
Update 12/07There is a difference in the baseline computation between RCTTextShadowView postprocessAttributedText and RCTTextAttributes effectiveParagraphStyle. Given the following example: <Text style={{lineHeight: 500, fontSize: 15, backgroundColor: 'red'}}>
font size 15
<Text style={{fontSize: 50, lineHeight: 500}}>font size 50</Text>
</Text>
|
Update 22/07 |
@fabOnReact any update on this one? |
@cead22 I think we should close this PR. This fork is not used anymore in newDot. |
The upstream PR was merged. I'm closing this PR. Thanks. |
Upstream PR Link
Upstream PR facebook#37465
fixes Expensify/App#17767
Summary:
Adding paragraphStyle.maximumLineHeight to a iOS UITextField displays the text under the UITextField (ios-screenshot-1, ios-screenshot-2, ios-screenshot-3). The issue reproduces on Storyboard App (iOS) using UITextField and paragraphStyle.maximumLineHeight. It is not caused by react-native.
The issue is caused by a private class _UITextLayoutFragmentView (a CALayer children of UITextField), which assumes the wrong position when setting the lineHeight. _UITextLayoutFragmentView frame's y coordinates are set to 30, instead of 0 (react-native-screenshot-1, react-native-screenshot-2)
The issue causes the below text Sdfsd to display under the TextInput.
I was able to fix the issue and correctly align the private layout view _UITextLayoutFragmentView using the public API RCTUITextField textRectForBound, which allows modifying the UITextField frame and inset.
The solution consists in the following steps, applied only to UITextField with lineHeight prop:
fixes facebook#28012
Changelog:
[IOS] [FIXED] - Fix TextInput vertical alignment issue when using lineHeight prop on iOS (Paper - old arch)
Test Plan:
Extensive tests included in the PR comments facebook#37465 (comment) and below