-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Add height block support to dimension #71914
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
Conversation
|
Size Change: +228 B (+0.01%) Total Size: 2.58 MB
ℹ️ View Unchanged
|
|
A quick scan of the block shows the following blocks that have a
|
|
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. |
aaronrobertshaw
left a comment
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 for putting this one together 🙇
After a quick glance at this PR, it shares some issues with the related width support PR - #71905.
I've left a couple of quick comments below that might help refine the approach here.
I hope that helps.
packages/block-editor/src/components/global-styles/dimensions-panel.js
Outdated
Show resolved
Hide resolved
|
We are going to punt the Icon Block to 7.0, so we might want to change the status of this PR as well. |
beb1bce to
e2cf62f
Compare
e2cf62f to
5cf3c3c
Compare
|
Flaky tests detected in badf4ff. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/20150012523
|
5cf3c3c to
b29ff4f
Compare
3cfabac to
bb1be96
Compare
c4727c2 to
80a1ef7
Compare
|
I've added a quick demo of the current height support in action, showing global styles and block support styles working together. The use of presets for the width and height supports is planned for a follow-up after landing this initial version as it will also require creation of a shared preset input control to avoid reimplementing similar preset controls as the spacing sizes and border radius controls already have. I have something in the works on this front. As this PR stands I think it's ready for some initial reviews. One known issue is after the consolidation of block inspector and global styles panels, the default display of controls became out of whack. It still needs a fix on this PR or in a follow up. |
f11ac4f to
2843130
Compare
1d249ca to
fb034e8
Compare
|
Thanks for the speedy review @ramonjd 👍
I believe it will need that tweak. It's on my list but I needed to improve some aspects of the underlying PR extracting the PresetInputControl component first. That's been done and this PR rebased now too, so I'll circle back to this |
|
I've added the same handling for |
7292898 to
4cd95fd
Compare
| inlineStyleOverrides.minHeight = 'unset'; | ||
| } else if ( minHeight || style?.dimensions?.minHeight ) { | ||
| // To ensure the minHeight does not get overridden by `aspectRatio` unset any existing rule. | ||
| inlineStyleOverrides.height = 'unset'; |
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.
I wonder why we're doing these things at the rendering level, can't we "unset" in the UI? Or do we even need to be this smart? (Maybe we do, just asking)
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.
I don't have full context on the original decision to handle this in this manner but @andrewserong might be able to shed further light.
The PR introducing aspect ratio support was #56897 and details the following for the "why" behind it.
This PR tries to let the CSS aspect-ratio work the way that it works, with minimal interference. To achieve this, and to avoid overflow issues, when an aspect ratio is set, we unset any value for min-height. Similarly, if a min-height is set at the block level, we output an aspect-ratio: unset rule to override any aspect ratio set in global styles. These unset rules should only be output for blocks that opt-in to aspect ratio, and are not saved to post content.
Before seeing that, my understanding was that the chosen approach was based on the block inspector not having access to the full set of global styles or third-party stylesheets. Now that global styles data is available in the post editor, most use cases should be addressable directly through the UI.
This also relates to how style inheritance is handled in the inspector. With those values exposed, the UI could more reliably determine things like aspect ratio versus min-height versus height, even if theme-enqueued stylesheets remain outside that scope.
Overall, the current approach seems slightly more robust.
|
This is looking good, how feasible is it to migrate the existing blocks with "height" attributes? (follow-ups probably) |
It's definitely coming along 👍 You're right, any migrations of blocks should be separate follow-ups. They'll all need to involve deprecations, which always tend to be a pain and uncover incorrect deprecations made in the past that need fixing. Separate follow ups should make for easier reviews and splitting up the work. As for the feasibility of migrating blocks, I don't see any blockers at this stage. It'll be nice to see all the ad hoc height solutions consolidated. Same for widths, etc, too. |
2843130 to
818cfe7
Compare
4cd95fd to
badf4ff
Compare
0c6a323 to
f55f845
Compare
badf4ff to
66c1d6a
Compare
|
The two PRs forming the basis for this PR have been merged. So this should be ready for another review. |
ramonjd
left a comment
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 work here, thanks for sticking with it for the back and forth.
- block styles work and override global styles
- global styles override theme.json
- theme.json settings and block styles work
- controls appear when and where they should 😄
Obligatory screenshot.
Just had a question about a potential UX follow up otherwise LGTM
Based on:
What?
This PR adds
heighttodimensionsblock supports. This was split out from #71905.Blocks wth
heightattributes:Why?
Part of the work being done in #71227 is to remove the custom width and height controls in favor of customizations via block supports. This PR handles the
heightblock supports portion.How?
Extending the existing
dimensionssupports object.Testing Instructions
heightblock support for both a static and dynamic block (e.g. paragraph & cover) via their block.json filessettings.dimensions.height: falseExample block.json dimensions config:
Example theme.json height styles:
Demos
The video below demonstrates a Cover block with height block support opted into. First, a global style is set to apply a consistent height to Cover blocks (note Cover blocks also have a default min-height). This is then overridden by the block instance applying a height support style.
Screen.Recording.2025-11-14.at.12.05.50.am.mp4