-
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
Spacing presets: Implement disabling of custom space sizes #43216
Conversation
Size Change: +7 B (0%) Total Size: 1.28 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 is testing nicely for me @glendaviesnz:
✅ Padding in the block editor defaults to allowing custom values, but hides the toggle when customSpacingSize
is set to false
✅ Padding in the site editor / global styles defaults to allowing custom values, but hides the toggle when customSpacingSize
is set to false
This isn't blocking for merging, but something I wondered is how should the UI behave when there are blocks that already exist (or are added via block patterns) that contain custom values? With this PR applied, since the control can't be toggled to custom, with the block selected, it doesn't display the current padding value, even though there is one. Here's a screenshot:
In this example, it's a Group block with 10px
padding. Here's the markup:
Group block markup
<!-- wp:group {"style":{"spacing":{"padding":{"top":"10px","right":"10px","bottom":"10px","left":"10px"}}},"backgroundColor":"vivid-red"} -->
<div class="wp-block-group has-vivid-red-background-color has-background" style="padding-top:10px;padding-right:10px;padding-bottom:10px;padding-left:10px"><!-- wp:paragraph -->
<p>A paragraph in an existing Group</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group -->
<!-- wp:group -->
<div class="wp-block-group"><!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|60","right":"var:preset|spacing|60","bottom":"var:preset|spacing|60","left":"var:preset|spacing|60"}}},"backgroundColor":"vivid-green-cyan"} -->
<div class="wp-block-group has-vivid-green-cyan-background-color has-background" style="padding-top:var(--wp--preset--spacing--60);padding-right:var(--wp--preset--spacing--60);padding-bottom:var(--wp--preset--spacing--60);padding-left:var(--wp--preset--spacing--60)"><!-- wp:paragraph -->
<p>A paragraph in a new Group</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group --></div>
<!-- /wp:group -->
From my perspective, I don't think this is a blocking issue, because I imagine that themes that use this setting would likely be attempting to prevent users from using values outside of the presets anyway, so might just be a bit of an edge case?
Good question. I think we should leave it with custom values being disabled even if a block has them set and revisit it if there is any user feedback that this is causing issues. |
Sounds good 👍 |
What?
Implements the ability to disable custom sizes - at this point just for padding, via the new spacing presets UI.
Why?
Theme and plugin authors have been asking for the ability to prevent users from adding custom sizes and only allowing them to select from a list of presets
How?
Wires the
settings.spacing.customSpacingSize
property that was prepared earlier through to the new spacing presets UI.Testing Instructions
settings.spacing.customSpacingSize
to falseScreenshots or screencast
Before:
no-space-before.mp4
After:
no-space-after.mp4