-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix invalid css for nested fullwidth layouts with zero padding applied #63436
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +1.74 kB (+0.1%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
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.
This tests well for me 👍 And the code also looks good
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.
Nice fix! I just pushed a tiny fix for a linting issue.
I'll open a backport PR and link it in this PR and then see about landing this and cherry picking it into the GB 18.8 release.
Backport open in: WordPress/wordpress-develop#7036 and in trac: https://core.trac.wordpress.org/ticket/61656 |
…g applied (#63436) * apply a default unit when set to zero (frontend) * apply a default unit when set to zero (editor) * use 0 as a string * Fix linting issue * Add backport changelog entry --------- Co-authored-by: Andrew Serong <[email protected]> Co-authored-by: richtabor <[email protected]> Co-authored-by: andrewserong <[email protected]> Co-authored-by: fabiankaegy <[email protected]>
I just cherry-picked this PR to the release/18.8 branch to get it included in the next release: 577dc63 |
$padding_right = $block_spacing_values['declarations']['padding-right']; | ||
$padding_right = $block_spacing_values['declarations']['padding-right']; | ||
// Add unit if 0. | ||
if ( '0' === $padding_right ) { |
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.
Are we guaranteed to get a string back from gutenberg_style_engine_get_styles
? I'm wondering if $padding_right
could sometimes be 0
not '0'
.
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.
At a quick glance, the value is passed through the style engine's is_valid_style_value
function. Which should exclude an integer 0
.
protected static function is_valid_style_value( $style_value ) {
return '0' === $style_value || ! empty( $style_value );
}
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.
Good question. I don't think gutenberg_style_engine_get_styles
will coerce the value for declarations from a quick look at the code, but padding values set by the UI will always be strings, and it's expected that values for spacing will be strings, I believe.
That said, this could be hardened in a follow-up to be if ( '0' === $padding_right || 0 === $padding_right ) {
and similarly for the left padding.
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, I missed that one, Aaron! 👍
Tested this against |
Same result for me with |
…padding applied In the Layout block support, handle 0 values for padding as 0px in calc() rules. This resolves a bug for nested fullwidth layouts when zero padding is applied. Due to how calc() works, without supplying the unit, the rule will not work, resulting in a horizontal scrollbar. Backports the PHP changes in WordPress/gutenberg#63436. Fixes #61656. Props andrewserong, mukesh27, aaronrobertshaw. git-svn-id: https://develop.svn.wordpress.org/trunk@58750 602fd350-edb4-49c9-b593-d223f7449a82
…padding applied In the Layout block support, handle 0 values for padding as 0px in calc() rules. This resolves a bug for nested fullwidth layouts when zero padding is applied. Due to how calc() works, without supplying the unit, the rule will not work, resulting in a horizontal scrollbar. Backports the PHP changes in WordPress/gutenberg#63436. Fixes #61656. Props andrewserong, mukesh27, aaronrobertshaw. Built from https://develop.svn.wordpress.org/trunk@58750 git-svn-id: http://core.svn.wordpress.org/trunk@58152 1a063a9b-81f0-0310-95a4-ce76da25c4cd
…padding applied In the Layout block support, handle 0 values for padding as 0px in calc() rules. This resolves a bug for nested fullwidth layouts when zero padding is applied. Due to how calc() works, without supplying the unit, the rule will not work, resulting in a horizontal scrollbar. Backports the PHP changes in WordPress/gutenberg#63436. Fixes #61656. Props andrewserong, mukesh27, aaronrobertshaw. Built from https://develop.svn.wordpress.org/trunk@58750 git-svn-id: https://core.svn.wordpress.org/trunk@58152 1a063a9b-81f0-0310-95a4-ce76da25c4cd
…g applied (#63436) * apply a default unit when set to zero (frontend) * apply a default unit when set to zero (editor) * use 0 as a string * Fix linting issue * Add backport changelog entry --------- Co-authored-by: Andrew Serong <[email protected]> Co-authored-by: richtabor <[email protected]> Co-authored-by: andrewserong <[email protected]> Co-authored-by: fabiankaegy <[email protected]>
I just cherry-picked this PR to the wp/6.6 branch to get it included in the next release: 2d33b15 |
Bugfixes included: * [WordPress/gutenberg#63637 Elements: Avoid specificity bump for top-level element-only selectors]. * [WordPress/gutenberg#63406 Navigation block: Allow themes to override block library text-decoration rule]. * [WordPress/gutenberg#63436 Fix invalid css for nested fullwidth layouts with zero padding applied]. * [WordPress/gutenberg#63397 Prevent empty void at the bottom of editor when block directory results are present]. * [WordPress/gutenberg#63291 Pattern overrides: Ensure "Reset" button always shows as last item and with border]. * [WordPress/gutenberg#63562 Global Styles: Disable "Reset styles" button when there are no changes]. * [WordPress/gutenberg#63093 Fix: Removed shuffle button when only 1 pattern is present]. * [WordPress/gutenberg#62675 fix: wp icon focus issue]. * [WordPress/gutenberg#63565 useBlockElement: return null until ref callback has time to clean up the old element]. Props ellatrix. Fixes #61692. See #61660, #61630, #61656. git-svn-id: https://develop.svn.wordpress.org/trunk@58757 602fd350-edb4-49c9-b593-d223f7449a82
Bugfixes included: * [WordPress/gutenberg#63637 Elements: Avoid specificity bump for top-level element-only selectors]. * [WordPress/gutenberg#63406 Navigation block: Allow themes to override block library text-decoration rule]. * [WordPress/gutenberg#63436 Fix invalid css for nested fullwidth layouts with zero padding applied]. * [WordPress/gutenberg#63397 Prevent empty void at the bottom of editor when block directory results are present]. * [WordPress/gutenberg#63291 Pattern overrides: Ensure "Reset" button always shows as last item and with border]. * [WordPress/gutenberg#63562 Global Styles: Disable "Reset styles" button when there are no changes]. * [WordPress/gutenberg#63093 Fix: Removed shuffle button when only 1 pattern is present]. * [WordPress/gutenberg#62675 fix: wp icon focus issue]. * [WordPress/gutenberg#63565 useBlockElement: return null until ref callback has time to clean up the old element]. Props ellatrix. Fixes #61692. See #61660, #61630, #61656. Built from https://develop.svn.wordpress.org/trunk@58757 git-svn-id: http://core.svn.wordpress.org/trunk@58159 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Bugfixes included: * [WordPress/gutenberg#63637 Elements: Avoid specificity bump for top-level element-only selectors]. * [WordPress/gutenberg#63406 Navigation block: Allow themes to override block library text-decoration rule]. * [WordPress/gutenberg#63436 Fix invalid css for nested fullwidth layouts with zero padding applied]. * [WordPress/gutenberg#63397 Prevent empty void at the bottom of editor when block directory results are present]. * [WordPress/gutenberg#63291 Pattern overrides: Ensure "Reset" button always shows as last item and with border]. * [WordPress/gutenberg#63562 Global Styles: Disable "Reset styles" button when there are no changes]. * [WordPress/gutenberg#63093 Fix: Removed shuffle button when only 1 pattern is present]. * [WordPress/gutenberg#62675 fix: wp icon focus issue]. * [WordPress/gutenberg#63565 useBlockElement: return null until ref callback has time to clean up the old element]. Props ellatrix. Fixes #61692. See #61660, #61630, #61656. Built from https://develop.svn.wordpress.org/trunk@58757 git-svn-id: https://core.svn.wordpress.org/trunk@58159 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Bugfixes included: * [WordPress/gutenberg#63637 Elements: Avoid specificity bump for top-level element-only selectors]. * [WordPress/gutenberg#63406 Navigation block: Allow themes to override block library text-decoration rule]. * [WordPress/gutenberg#63436 Fix invalid css for nested fullwidth layouts with zero padding applied]. * [WordPress/gutenberg#63397 Prevent empty void at the bottom of editor when block directory results are present]. * [WordPress/gutenberg#63291 Pattern overrides: Ensure "Reset" button always shows as last item and with border]. * [WordPress/gutenberg#63562 Global Styles: Disable "Reset styles" button when there are no changes]. * [WordPress/gutenberg#63093 Fix: Removed shuffle button when only 1 pattern is present]. * [WordPress/gutenberg#62675 fix: wp icon focus issue]. * [WordPress/gutenberg#63565 useBlockElement: return null until ref callback has time to clean up the old element]. Reviewed by spacedmonkey. Merges [58757] to the 6.6 branch. Props ellatrix. Fixes #61692. See #61660, #61630, #61656. git-svn-id: https://develop.svn.wordpress.org/branches/6.6@58760 602fd350-edb4-49c9-b593-d223f7449a82
Bugfixes included: * [WordPress/gutenberg#63637 Elements: Avoid specificity bump for top-level element-only selectors]. * [WordPress/gutenberg#63406 Navigation block: Allow themes to override block library text-decoration rule]. * [WordPress/gutenberg#63436 Fix invalid css for nested fullwidth layouts with zero padding applied]. * [WordPress/gutenberg#63397 Prevent empty void at the bottom of editor when block directory results are present]. * [WordPress/gutenberg#63291 Pattern overrides: Ensure "Reset" button always shows as last item and with border]. * [WordPress/gutenberg#63562 Global Styles: Disable "Reset styles" button when there are no changes]. * [WordPress/gutenberg#63093 Fix: Removed shuffle button when only 1 pattern is present]. * [WordPress/gutenberg#62675 fix: wp icon focus issue]. * [WordPress/gutenberg#63565 useBlockElement: return null until ref callback has time to clean up the old element]. Reviewed by spacedmonkey. Merges [58757] to the 6.6 branch. Props ellatrix. Fixes #61692. See #61660, #61630, #61656. Built from https://develop.svn.wordpress.org/branches/6.6@58760 git-svn-id: http://core.svn.wordpress.org/branches/6.6@58162 1a063a9b-81f0-0310-95a4-ce76da25c4cd
…padding applied In the Layout block support, handle 0 values for padding as 0px in calc() rules. This resolves a bug for nested fullwidth layouts when zero padding is applied. Due to how calc() works, without supplying the unit, the rule will not work, resulting in a horizontal scrollbar. Ref: PHP changes from WordPress/gutenberg#63436. Reviewed by hellofromTonya. Merges [58750] to the 6.6 branch. Fixes #61656. Props andrewserong, mukesh27, aaronrobertshaw. git-svn-id: https://develop.svn.wordpress.org/branches/6.6@58761 602fd350-edb4-49c9-b593-d223f7449a82
…padding applied In the Layout block support, handle 0 values for padding as 0px in calc() rules. This resolves a bug for nested fullwidth layouts when zero padding is applied. Due to how calc() works, without supplying the unit, the rule will not work, resulting in a horizontal scrollbar. Ref: PHP changes from WordPress/gutenberg#63436. Reviewed by hellofromTonya. Merges [58750] to the 6.6 branch. Fixes #61656. Props andrewserong, mukesh27, aaronrobertshaw. Built from https://develop.svn.wordpress.org/branches/6.6@58761 git-svn-id: http://core.svn.wordpress.org/branches/6.6@58163 1a063a9b-81f0-0310-95a4-ce76da25c4cd
…g applied (WordPress#63436) * apply a default unit when set to zero (frontend) * apply a default unit when set to zero (editor) * use 0 as a string * Fix linting issue * Add backport changelog entry --------- Co-authored-by: Andrew Serong <[email protected]> Co-authored-by: richtabor <[email protected]> Co-authored-by: andrewserong <[email protected]> Co-authored-by: fabiankaegy <[email protected]>
What?
Closes #63432 by ensuring a
px
unit is provided, to do the proper calculation when padding left or right is set to the string value of0
via the padding controls.Why?
Nested fullwidth blocks have outer padding properly negated, but when you use a custom padding value, that value is used to negate the margins, rather than the outer padding. This works great for every case where a unit is supplied with the custom value (as is always the case, other than when the value is
0
.Testing Instructions
Visuals
Before
With unintentional horizontal scroll:
CleanShot.2024-07-11.at.09.20.11.mp4
After
With no horizontal scroll:
CleanShot.2024-07-11.at.09.29.05.mp4