Skip to content

Conversation

@noahtallen
Copy link
Contributor

@noahtallen noahtallen commented Oct 27, 2020

Changes proposed in this Pull Request

In WordPress/gutenberg#25738, Gutenberg moved the lineHeight setting to a new place in the settings object. It also introduced a (sort of?) bug where even though it has a mechanism to use the deprecated location for the setting, it is never used because the default value is returned instead.

This simply updates our existing filter to enable line height in the new location if the new location exists. I left the old setting in place as well, just in case we still need to support older gutenberg versions.

To test:

  1. Sandbox a site on wordpress.com
  2. Sync these changes with yarn dev --sync
  3. Open the post editor.
  4. Select a paragraph block
  5. Verify that line height is an option in the settings.

Screen Shot 2020-10-26 at 6 07 47 PM

@noahtallen noahtallen added [Type] Bug When a feature is broken and / or not performing as intended [Pri] Normal Schedule for the next available opportuinity. Editing Toolkit For issues and PRs that affect the Editing Toolkit plugin labels Oct 27, 2020
@noahtallen noahtallen self-assigned this Oct 27, 2020
@matticbot
Copy link
Contributor

@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Oct 27, 2020
@noahtallen
Copy link
Contributor Author

cc @jorgefilipecosta @nosolosw. What would be the ideal way to handle this use case? Specifically, we are using a filter to override gutenberg editor settings to always enable the line-height settings. This is because many of the themes on WordPress.com haven't opted-in to the setting yet, even though it works fine. (Plus, we had a lot of users using the feature before it was delegated to theme support!)

Is this approach fine? Is there a better way to specify what the default setting should be for that variable?

Copy link
Contributor

@fullofcaffeine fullofcaffeine left a comment

Choose a reason for hiding this comment

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

Works great 👍🏻

@matticbot
Copy link
Contributor

Caution: This PR affects files in the Editing Toolkit Plugin on WordPress.com
Please ensure your changes work on WordPress.com before merging.

D51824-code has been created so you can easily test it on your sandbox. See this FieldGuide page about developing the Editing Toolkit Plugin for more info: PCYsg-ly5-p2

@matticbot
Copy link
Contributor

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

@ockham
Copy link
Contributor

ockham commented Oct 27, 2020

Building the ETP release is apparently blocked by #46811 currently 😕

@ockham
Copy link
Contributor

ockham commented Oct 27, 2020

Building the ETP release is apparently blocked by #46811 currently

Disregard, applying D51824-code to my sandbox works just fine.

Copy link
Contributor

@ockham ockham left a comment

Choose a reason for hiding this comment

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

Working well 👍

Copy link
Contributor

@WunderBart WunderBart left a comment

Choose a reason for hiding this comment

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

Testing via yarn dev --sync doesn't work for me because of the issue mentioned by @ockham, but after applying the corresponding diff D51824-code I was finally able to test it. All good, thanks! 🚢

@ockham ockham merged commit d1a3351 into master Oct 27, 2020
@ockham ockham deleted the fix/custom-line-height-filter branch October 27, 2020 20:29
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Oct 27, 2020
**/
function wpcom_gutenberg_enable_custom_line_height( $settings ) {
$settings['enableCustomLineHeight'] = true;
if ( isset( $settings['__experimentalFeatures']['global']['typography'] ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi, I've already commented that this is a bug we need to fix, see WordPress/gutenberg#26537

I was thinking of a way to do it that's more robust than using __experimental.global.typography.customLineHeight (the shape of this can change as it's still experimental). What if you hook this function to after_setup_theme and make it declare theme support like add_theme_support('custom-line-height')?

Copy link
Contributor

Choose a reason for hiding this comment

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

Made it more robust here: #46873. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Editing Toolkit For issues and PRs that affect the Editing Toolkit plugin [Pri] Normal Schedule for the next available opportuinity. [Type] Bug When a feature is broken and / or not performing as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants