Skip to content
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

Mobile - Fix line-height issue on Android #37285

Merged
merged 2 commits into from
Dec 28, 2021

Conversation

geriux
Copy link
Member

@geriux geriux commented Dec 10, 2021

Fixes #37168

Description

This PR fixes an issue where the line-height value wouldn't be set after a font-size value was changed. Now it'll store the current line-height value and it'll be refreshed after any font size change.

Note: This feature is still under the __DEV__ flag only available running metro.

How has this been tested?

Precondition: Have a block-based theme activated.

  • Open the WordPress Android app with metro running and setting the localGutenbergMobilePath path.
  • Add a Heading block
  • Type some text, with enough characters to fill in at least two lines
  • Expect the line height to be shown correctly

Screenshots

Before After

Types of changes

Bug fix

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

@geriux geriux added the Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) label Dec 10, 2021
@geriux geriux added the [Status] In Progress Tracking issues with work in progress label Dec 10, 2021
@geriux geriux requested a review from antonis December 22, 2021 10:38
@geriux geriux removed the [Status] In Progress Tracking issues with work in progress label Dec 22, 2021
@geriux geriux marked this pull request as ready for review December 22, 2021 10:47
@hypest
Copy link
Contributor

hypest commented Dec 22, 2021

👋 @geriux ! Antonis is AFK until a few more days so I thought of giving this a look from my side, hope that's OK.

I'm wondering, wdyt about perhaps using View.getLineSpacingExtra() or View.getLineSpacingMultiplier() (and View.getTextSize()) to work back from the setLineSpacing calculations to recover the current line height used, instead of maintaining a member variable for it? Not a big problem using a member variable, just wondering if we'd prefer to not have to maintain one (and need to make sure it is kept n sync in all the proper places)?

@geriux
Copy link
Member Author

geriux commented Dec 22, 2021

I thought of giving this a look from my side, hope that's OK.

Of course! Any feedback is more than welcome 🙇

When I started debugging this issue I tried getting the current values with those methods but I couldn't get the exact initial line-height value, I'll try those again to see what results I get 👍

@hypest
Copy link
Contributor

hypest commented Dec 22, 2021

When I started debugging this issue I tried getting the current values with those methods but I couldn't get the exact initial line-height value, I'll try those again to see what results I get 👍

Oh, I see. I didn't see a mention in the PR description so wasn't sure if you tried. FWIW, I haven't tried it myself so, your testing is already more complete apparently 😃

Copy link
Member

@antonis antonis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for wrangling this @geriux 🙇‍♂️
I tested the implementation on a Pixel 5 (Android 12) running metro and setting the localGutenbergMobilePath path with the head of WordPress-Android develop and everything works as expected. The code changes also look consistent to me 🎉

@geriux
Copy link
Member Author

geriux commented Dec 28, 2021

I'm wondering, wdyt about perhaps using View.getLineSpacingExtra() or View.getLineSpacingMultiplier() (and View.getTextSize()) to work back from the setLineSpacing calculations to recover the current line height used, instead of maintaining a member variable for it? Not a big problem using a member variable, just wondering if we'd prefer to not have to maintain one (and need to make sure it is kept n sync in all the proper places)?

While checking this I also remembered why I ended up with this approach, the line-height needs to be refreshed after a font size change has happened and only when there's a current line-height set. I tried to see if there's a way to get the react-native props that were set but I couldn't so I used the variable instead. I'll merge this change for now, thanks for the feedback and review! 🙇

@geriux geriux merged commit 1363478 into trunk Dec 28, 2021
@geriux geriux deleted the rnmobile/fix/line-height-android branch December 28, 2021 12:28
@github-actions github-actions bot added this to the Gutenberg 12.3 milestone Dec 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrapping Heading block text overlaps previous lines for block-based themes
3 participants