Skip to content

Cover: Migrate the minimum height to the dimensions block support - #83447

Open
t-hamano wants to merge 4 commits into
trunkfrom
update/cover-min-height-block-support
Open

t-hamano wants to merge 4 commits into
trunkfrom
update/cover-min-height-block-support

Conversation

@t-hamano

@t-hamano t-hamano commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

What?

Move the Cover block's minimum height from the minHeight and minHeightUnit attributes to the dimensions.minHeight block support.

Why?

dimensions.minHeight is already supported by several blocks, and its control offers the presets a theme defines in dimensions.dimensionSizes. Cover is the only block that stores a minimum height as its own attribute, so those presets are unavailable to it.

The presets could be wired into the existing attribute with useSettings and a preset-aware control, but re-implementing what the block support already provides did not feel right.

How?

dimensions.minHeight is false by default, and Cover has to keep offering a minimum height to every theme as it does today. The block therefore opts in at the block level in lib/theme.json, the same approach taken for the Button block's width support in #74242 and the Icon block's width setting in #75665.

Testing Instructions

Each step replaces test/emptytheme/theme.json with the JSON shown.

1. Theme presets are available on Cover

{
	"version": 3,
	"settings": {
		"appearanceTools": true,
		"dimensions": {
			"dimensionSizes": [
				{ "name": "Small", "slug": "small", "size": "clamp(150px, 20vh, 200px)" },
				{ "name": "Medium", "slug": "medium", "size": "clamp(250px, 40vh, 400px)" },
				{ "name": "Large", "slug": "large", "size": "clamp(400px, 60vh, 600px)" },
				{ "name": "Full", "slug": "full", "size": "100vh" }
			]
		},
		"layout": {
			"contentSize": "840px",
			"wideSize": "1100px"
		}
	}
}

Minimum height should present the four presets, and picking one should store var:preset|dimension|<slug> and render the matching min-height in the canvas and on the front end.

2. Block-level presets win over root-level ones

{
	"version": 3,
	"settings": {
		"appearanceTools": true,
		"dimensions": {
			"dimensionSizes": [
				{ "name": "Root 1", "slug": "root-1", "size": "100px" },
				{ "name": "Root 2", "slug": "root-2", "size": "200px" },
				{ "name": "Root 3", "slug": "root-3", "size": "300px" }
			]
		},
		"blocks": {
			"core/cover": {
				"dimensions": {
					"dimensionSizes": [
						{ "name": "Cover 1", "slug": "cover-1", "size": "400px" },
						{ "name": "Cover 2", "slug": "cover-2", "size": "500px" },
						{ "name": "Cover 3", "slug": "cover-3", "size": "600px" }
					]
				}
			}
		},
		"layout": {
			"contentSize": "840px",
			"wideSize": "1100px"
		}
	}
}

Cover should offer only the three Cover presets. A Group block, which has no block-level override, should still offer the three Root ones.

3. A theme can turn the control off

{
	"version": 3,
	"settings": {
		"appearanceTools": true,
		"blocks": {
			"core/cover": {
				"dimensions": { "minHeight": false }
			}
		},
		"layout": {
			"contentSize": "840px",
			"wideSize": "1100px"
		}
	}
}

Minimum height should disappear from the Dimensions panel, the Full height button should disappear from the block toolbar, and the resize handle at the bottom of the selected Cover block should no longer appear. The Group block keeps its own Minimum height.

Screenshots or screencast

min-height-block-support.mp4

Use of AI Tools

The change was implemented with Claude Code, then reviewed and tested by me. The commit carries a Co-Authored-By trailer.

@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Sep 23, 2026
@t-hamano
t-hamano force-pushed the update/cover-min-height-block-support branch from a1794ca to e98bb78 Compare September 23, 2026 10:28
@t-hamano t-hamano self-assigned this Sep 23, 2026
@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. [Block] Cover Affects the Cover Block - used to display content laid over a background image labels Sep 23, 2026
…accepts theme presets

Co-Authored-By: Claude <noreply@anthropic.com>
@t-hamano
t-hamano force-pushed the update/cover-min-height-block-support branch from e98bb78 to f3df063 Compare September 23, 2026 10:52
@t-hamano
t-hamano marked this pull request as ready for review September 23, 2026 10:53
@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: richtabor <richtabor@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

📦 Bundle size

Size Change: -228 B (0%)

Total Size: 8.24 MB

📦 View Changed
Filename Size Change
build/scripts/block-library/index.min.js 365 kB -228 B (-0.06%)

734ec9e Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 17df2da trunk % Change
timeToFirstByte 36.45 ms +12.07% -4.25% 34.75 ms +6.76% -3.74% 4.89%
largestContentfulPaint 62 ms +6.45% -3.23% 60 ms +3.33% -6.67% 3.33%
lcpMinusTtfb 24.95 ms +5.01% -4.61% 23.1 ms +9.96% -3.25% 8.01%
wpBeforeTemplate 18 ms +18.28% -2.44% 17.29 ms +8.33% -2.78% 4.11%
wpTemplate 14.97 ms +4.74% -2.54% 14.46 ms +5.53% -4.77% 3.53%
wpTotal 33.53 ms +12.56% -4.15% 31.85 ms +7.79% -3.7% 5.27%
wpMemoryUsage 7.61 MB +0% -0% 7.57 MB +0% -0% 0.53%
wpDbQueries 17 +0% -0% 17 +0% -0% 0%

front-end-classic-theme

Metric 17df2da trunk % Change
timeToFirstByte 30.85 ms +4.54% -4.54% 26.55 ms +10.17% -3.01% 16.2%
largestContentfulPaint 70 ms +2.86% -2.86% 60 ms +6.67% -0% 16.67%
lcpMinusTtfb 38.8 ms +7.35% -4.12% 34.25 ms +3.94% -2.34% 13.28%
wpBeforeTemplate 16.06 ms +15.38% -1.87% 15.8 ms +11.77% -2.59% 1.65%
wpTemplate 11.17 ms +12.62% -2.24% 8.26 ms +2.06% -2.91% 35.23%
wpTotal 28.04 ms +5.96% -3.92% 24.15 ms +11.47% -3.19% 16.11%
wpMemoryUsage 6.23 MB +0% -0% 6.05 MB +0% -0% 2.88%
wpDbQueries 14 +0% -0% 10 +0% -0% 40%

media-processing

Metric 17df2da trunk % Change
mediaProcessingJpeg 226.96 ms +0.3% -2.57% 219.8 ms +1.11% -1.47% 3.26%
mediaProcessingAvif 3627.84 ms +0.4% -0.36% 3457.76 ms +0.94% -0.27% 4.92%
mediaProcessingJpegToAvif 2523.67 ms +0.06% -0.77% 2421.09 ms +0.76% -0.12% 4.24%

media-upload

Metric 17df2da trunk % Change
jpegUploadProcessing 898.44 ms +56.28% -1.57% 899.66 ms +0.15% -1.09% -0.14%
pngUploadProcessing 149.63 ms +6.13% -1.17% 160.46 ms +6.19% -0.95% -6.75%
largeJpegUploadProcessing 883.51 ms +1.04% -0.55% 896.07 ms +53.89% -1.86% -1.4%
multipleImageUploadProcessing 1445.56 ms +0.85% -8.47% 1424.04 ms +4.24% -27.34% 1.51%

post-editor

Metric 17df2da trunk % Change
serverResponse 486.46 ms +8.92% -2.24% 510.01 ms +4.32% -4.61% -4.62%
firstPaint 227.5 ms +8.94% -9.71% 206.08 ms +14.19% -13.12% 10.39%
domContentLoaded 1107.18 ms +2.43% -1.01% 1083.68 ms +2.51% -0.38% 2.17%
loaded 1108.52 ms +2.43% -1.01% 1084.79 ms +2.52% -0.36% 2.19%
firstContentfulPaint 459.2 ms +3.79% -1.57% 439.12 ms +3.32% -11.66% 4.57%
firstBlock 3313.27 ms +1.25% -0.58% 3294.19 ms +1.85% -0.23% 0.58%
type 18.2 ms +4.67% -8.74% 18.73 ms +1.87% -4% -2.83%
typeWithoutInspector 17.97 ms +10.29% -5.56% 17.52 ms +7.31% -5.82% 2.57%
typeWithTopToolbar 22.35 ms +14.72% -3.94% 25.61 ms +8.79% -5.54% -12.73%
typeContainer 1.18 ms +15.25% -36.44% 1.25 ms +16.8% -33.6% -5.6%
focus 12.45 ms +9.96% -5.46% 13.88 ms +10.59% -11.67% -10.3%
firstFocus 29.8 ms +0% -0% 33.78 ms +0% -0% -11.78%
selectAll 1541.42 ms +0.04% -2.43% 1552.16 ms +1.95% -0.19% -0.69%
listViewOpen 65.85 ms +6.77% -13.06% 67.47 ms +8.8% -10.63% -2.4%
inserterOpen 23.48 ms +19.17% -13.88% 22.68 ms +8.99% -6.44% 3.53%
inserterHover 2.21 ms +7.69% -7.24% 2.16 ms +12.96% -5.09% 2.31%
inserterSearch 8.24 ms +8.25% -2.91% 7.83 ms +14.43% -2.3% 5.24%
loadPatterns 635.75 ms +5.27% -1.94% 629.26 ms +3.63% -2.76% 1.03%
wpTotal 476.63 ms +9% -2.36% 500.02 ms +4.39% -4.75% -4.68%
wpMemoryUsage 13.15 MB +0% -0% 13.11 MB +0% -0% 0.29%
wpDbQueries 54 +0% -0% 54 +0% -0% 0%

site-editor

Metric 17df2da trunk % Change
serverResponse 363.49 ms +7.7% -4.45% 374.57 ms +1.9% -1.9% -2.96%
firstPaint 226.23 ms +10.47% -12.59% 211.32 ms +19.36% -4.95% 7.06%
domContentLoaded 985.29 ms +2.37% -1.68% 963.36 ms +1.98% -2.02% 2.28%
loaded 986.31 ms +2.37% -1.69% 964.54 ms +1.94% -2.05% 2.26%
firstContentfulPaint 406.09 ms +5.38% -4.31% 388.64 ms +4.86% -3.61% 4.49%
firstBlock 3466.01 ms +2.75% -0.76% 3446.9 ms +0.46% -1.69% 0.55%
type 16.3 ms +11.53% -4.91% 16.07 ms +7.03% -3.61% 1.43%
navigate 92.49 ms +18.45% -2.42% 91.69 ms +13.51% -3.14% 0.87%
loadPatterns 1184.52 ms +23.01% -5.38% 1143.78 ms +12.5% -6.48% 3.56%
loadPages 1029 ms +3.23% -0.69% 1048.6 ms +0.3% -2.08% -1.87%
wpTotal 353.93 ms +7.94% -4.36% 365.46 ms +1.87% -1.99% -3.15%
wpMemoryUsage 12.13 MB +0% -0% 12.09 MB +0% -0% 0.32%
wpDbQueries 44 +0% -2.27% 44 +0% -2.27% 0%

734ec9e Run

@aaronrobertshaw

Copy link
Copy Markdown
Contributor

Thanks for getting this PR up @t-hamano 🚀

One aside before the review proper. In other recent design tools work, I was seeing that we might need a closer look at how dimension presets interact with the core defaults in lib/theme.json. I suspect they don't de-dupe. FWIW I have some local explorations, but I need a window to shift focus onto it.

Backward compatibility holds up for the most part. Two blockers.

Blockers

The resize handle isn't gated with the rest. In your test 3 the control and the Full height button both go, but the drag handle stays. The user can still drag in a value they can't then see or clear, and it renders on the front end.

Nothing replaces the 50px floor. The shared DimensionControl hardcodes a floor of 0 and a block can't raise it. With presets defined, None writes 0 and takes the block below the 430px default.

That might well be what we want, clearing Cover's minimum height has been asked for often enough. I'd rather it was a decision than a side effect though.

Worth fixing

Two knock-ons from the opt-in. Core's theme.json needs the same entry landed with the backport. And anywhere theme.json settings aren't loaded, say a block editor embedded outside WordPress, the control goes entirely.

Block settings beat root settings, whatever the source. A theme turning dimensions.minHeight off at the root still gets the control on Cover, and has to opt out per block. Worth a line in the description.

Deprecation gaps. v1 to v3 declare minHeight and didn't get the migration, though nothing visible is lost there. No fixture covers v10 to v14 markup carrying minHeight either.

The attribute removal needs a dev note. Saved content is fine, anything reading minHeight or minHeightUnit isn't. The CHANGELOG entry also sits under Enhancements.

@t-hamano

Copy link
Copy Markdown
Contributor Author

@aaronrobertshaw Thanks for the review!

The resize handle isn't gated with the rest. In your test 3 the control and the Full height button both go, but the drag handle stays. The user can still drag in a value they can't then see or clear, and it renders on the front end.

I disabled the UI for resizing when minHeight is disabled.

Nothing replaces the 50px floor. The shared DimensionControl hardcodes a floor of 0 and a block can't raise it. With presets defined, None writes 0 and takes the block below the 430px default.

That might well be what we want, clearing Cover's minimum height has been asked for often enough. I'd rather it was a decision than a side effect though.

My take is that allowing values below 50px, all the way down to 0, is acceptable. As for the None label, I think we might be abled to enhance the DimensionControl side—specifically, by having None apply undefined instead of 0, or by simply using a 0 label instead of None.

And anywhere theme.json settings aren't loaded, say a block editor embedded outside WordPress, the control goes entirely.

This applies to any effort to migrate attributes to block supports, doesn't it? I don't think it's an issue, as consumers can decide for themselves which npm version to use outside of WordPress.

Block settings beat root settings, whatever the source. A theme turning dimensions.minHeight off at the root still gets the control on Cover, and has to opt out per block. Worth a line in the description.
The attribute removal needs a dev note. Saved content is fine, anything reading minHeight or minHeightUnit isn't. The CHANGELOG entry also sits under Enhancements.

Once this PR is merged, I would like to summarize the key points for consumers in a dev note.

v1 to v3 declare minHeight and didn't get the migration, though nothing visible is lost there.

I think v1 to v3 don't declare minHeight

No fixture covers v10 to v14 markup carrying minHeight either.

Addressed in 734ec9e

This branch has not been deployed

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

Labels

[Block] Cover Affects the Cover Block - used to display content laid over a background image [Package] Block library /packages/block-library [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update cover block min height control to use HeightControl

2 participants