-
Notifications
You must be signed in to change notification settings - Fork 58
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
Remove extra padding on text blocks in Android #1560
Remove extra padding on text blocks in Android #1560
Conversation
Note: setting
|
Note we need to release a new Aztec version before merging that one. |
👋 @maxme I added two commits. The first one (c9050f6) removes unnecessary padding and the second one (7d2f7b7) is just cleaning up some css variables that we don't need anymore (so it is not strictly necessary). Cleaning up the css variables did require changes on the gutenberg side (gutenberg side PR). It appears that the reason we were still seeing excess padding is because that padding is applied due to the default background that is applied to In addition, React Native was internally using this padding by setting a The reason I also removed a few css variables is because previously we had these set differently on the two platforms in order to accommodate for the extra padding that was coming from Aztec views. For example, we were giving the Post Title no margins in order to make it look "right" with the extra padding from Aztec. In addition, it should be noted that I am removing a couple of margins/paddings for iOS as well. In my testing removing them made no difference, but I want to make sure someone else checks that as well.
|
Added this note to the PR description as well since this has tripped me up more than once. |
// (https://github.com/wordpress-mobile/gutenberg-mobile/issues/992) due to | ||
// https://github.com/facebook/react-native/blob/6ebd3b046e5b71130281f1a7dbe7220eff95d74a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputShadowNode.java#L70 | ||
} | ||
|
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.
Instead of preventing the default padding from being set like I am doing, an alternative approach that seems work just as well is to explicitly set padding to 0 on the ShadowNode
when it is constructed:
public ReactAztecTextShadowNode() {
super();
setPadding(Spacing.START, 0);
setPadding(Spacing.TOP, 0);
setPadding(Spacing.END, 0);
setPadding(Spacing.BOTTOM,0);
}
I do not have a strong preference between these two approaches, although it does seem nice how ignoring the default padding does not have us setting a padding of 0 both here and in the ReactAztecManager
. Both approaches do stop working if we remove the aztecText.setPadding(0, 0, 0, 0)
line in ReactAztecManager
(likely because then the default EditText
background controls the padding on the view).
Looks good to me. Before we can merge that one:
|
770d803
to
95b38fa
Compare
👋 @maxme ! Wanted to give you a heads up that I rebased these changes onto develop. The branch had gotten so out-of-date that adding another merge commit was getting a bit messy. In other words, be prepared for some conflicts if you try to just update your local copy of this branch. |
I have updated this branch with the latest code from Note that this fix will not fix the crash with respect to React Native The only way to recreate the crash is to create a post with a lot of paragraph blocks (500-1000 of them is what I use), and then you quickly scroll through the post for a while. I usually get a crash in a minute or two. If there's no crash after a minute or so I'll kill the app and restart it to try again. To give you an idea of how I recreate the crash, here is a video of my very scientific method for causing the crash. I know this PR has been up for quite a while now, but I think it is in good shape to review and 🤞 get merged. cc: @cameronvoell , @marecar3 , @SergioEstevao |
Hey @mchowning if this PR fixes the crash on Android, should we maybe update release notes in this PR, WDYT? thanks. |
* of customizing that class so that the construction of the dummy {@link EditText} instance | ||
* can be overridden (see {@link ReactTextInputShadowNodeFork#createDummyEditText(ThemedReactContext)}). | ||
*/ | ||
public class ReactTextInputShadowNodeFork extends ReactBaseTextShadowNode |
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.
Is there some plan on how can we follow improvements in ReactAztecTextShadowNode
or ReactBaseTextShadowNode
which will be potentially presented in the new version of RN?
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.
Not really. Ideally, we'll be able to get React Native itself updated to allow overriding the construction of the EditText
instance like this. Otherwise (and until then) we will just have to manually pull in any updates.
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.
Got this fix merged into React Native, so once we start using a version of React Native that includes that change, we won't need to have this ReactTextInputShadowNodeFork
anymore! 😄
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!
I think you're absolutely right @marecar3 ! I've added release notes addressing both the padding fix and the crash fix. |
f1af658
to
9b5f41e
Compare
In this commit, the fork does not yet contain any changes from the ReactTextInputShadow class. Those changes will come in subsequent commits.
…owNode Note that now that we are insuring that the dummy EditText does not have the default background (with its padding) we do not need to override (and ignore) the default padding method to prevent the dummy EditText's background from applying unwanted padding (because there is no background anymore).
9b5f41e
to
a919cdc
Compare
a919cdc
to
d4f990c
Compare
Fixes #992: Remove extra padding on text blocks.
Related gutenberg PR
yarn start:reset
. Otherwise the metro bundler will not reflect the css changes in this PR.Update release notes:
RELEASE-NOTES.txt
.