Skip to content
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

Add setting to disable custom content size controls #56236

Merged
merged 4 commits into from
Nov 28, 2023

Conversation

tellthemachines
Copy link
Contributor

@tellthemachines tellthemachines commented Nov 17, 2023

What?

Similar to the setting that allows disabling layout controls in #53378, this allows only the content and wide size controls for constrained layout to be disabled from theme.json, globally or at a per-block level (note that disabling globally only affects the controls displayed in the block sidebar, not the ones under global styles > layout)

Testing Instructions

  1. In theme.json under settings, add the following:
"blocks": {
	"core/group": {
		"layout": {
			"allowCustomContentAndWideSize": false
		}
	}
}
  1. Check that the Group block controls don't show custom content/wide size inputs:
Screenshot 2023-11-17 at 3 24 09 pm

@tellthemachines tellthemachines added [Type] Enhancement A suggestion for improvement. [Feature] Layout Layout block support, its UI controls, and style output. labels Nov 17, 2023
@tellthemachines tellthemachines self-assigned this Nov 17, 2023
Copy link

This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.

If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged.

If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack.

Thank you! ❤️

View changed files
❔ lib/class-wp-theme-json-gutenberg.php

'contentSize' => null,
'wideSize' => null,
'allowEditing' => null,
'allowCustomContentSize' => null,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if it might be worth adding some of the other settings that allow for disabling controls, such as allowOrientation or allowJustification. Currently these only work when set in block.json.

Copy link
Contributor

Choose a reason for hiding this comment

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

Great idea! To keep things contained, I reckon we could explore those in separate PRs?

const blockSupportAndThemeSettings = {
...layoutSettings,
...layoutBlockSupport,
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm undecided about the order of these. On one hand, it would make sense for it to be possible to override block default settings at a theme level. On the other, enabling layout controls on some blocks might result in a suboptimal experience (e.g. Gallery or Columns).

Copy link
Contributor

Choose a reason for hiding this comment

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

My understanding was that we'd want theme.json to be able to disable something set in block.json (i.e. hide controls) but never to enable something that the block itself hasn't opted into.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then the order is correct, assuming controls aren't explicitly set to true in block.json. Which they shouldn't be, because all controls display by default.

Copy link

github-actions bot commented Nov 17, 2023

Size Change: +24 B (0%)

Total Size: 1.7 MB

Filename Size Change
build/block-editor/index.min.js 248 kB +24 B (0%)
ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 964 B
build/annotations/index.min.js 2.71 kB
build/api-fetch/index.min.js 2.29 kB
build/autop/index.min.js 2.11 kB
build/blob/index.min.js 590 B
build/block-directory/index.min.js 7.25 kB
build/block-directory/style-rtl.css 1.04 kB
build/block-directory/style.css 1.04 kB
build/block-editor/content-rtl.css 4.29 kB
build/block-editor/content.css 4.28 kB
build/block-editor/default-editor-styles-rtl.css 403 B
build/block-editor/default-editor-styles.css 403 B
build/block-editor/style-rtl.css 15.7 kB
build/block-editor/style.css 15.7 kB
build/block-library/blocks/archives/editor-rtl.css 61 B
build/block-library/blocks/archives/editor.css 60 B
build/block-library/blocks/archives/style-rtl.css 90 B
build/block-library/blocks/archives/style.css 90 B
build/block-library/blocks/audio/editor-rtl.css 150 B
build/block-library/blocks/audio/editor.css 150 B
build/block-library/blocks/audio/style-rtl.css 122 B
build/block-library/blocks/audio/style.css 122 B
build/block-library/blocks/audio/theme-rtl.css 138 B
build/block-library/blocks/audio/theme.css 138 B
build/block-library/blocks/avatar/editor-rtl.css 116 B
build/block-library/blocks/avatar/editor.css 116 B
build/block-library/blocks/avatar/style-rtl.css 104 B
build/block-library/blocks/avatar/style.css 104 B
build/block-library/blocks/block/editor-rtl.css 305 B
build/block-library/blocks/block/editor.css 305 B
build/block-library/blocks/button/editor-rtl.css 587 B
build/block-library/blocks/button/editor.css 587 B
build/block-library/blocks/button/style-rtl.css 633 B
build/block-library/blocks/button/style.css 632 B
build/block-library/blocks/buttons/editor-rtl.css 337 B
build/block-library/blocks/buttons/editor.css 337 B
build/block-library/blocks/buttons/style-rtl.css 332 B
build/block-library/blocks/buttons/style.css 332 B
build/block-library/blocks/calendar/style-rtl.css 239 B
build/block-library/blocks/calendar/style.css 239 B
build/block-library/blocks/categories/editor-rtl.css 113 B
build/block-library/blocks/categories/editor.css 112 B
build/block-library/blocks/categories/style-rtl.css 124 B
build/block-library/blocks/categories/style.css 124 B
build/block-library/blocks/code/editor-rtl.css 53 B
build/block-library/blocks/code/editor.css 53 B
build/block-library/blocks/code/style-rtl.css 121 B
build/block-library/blocks/code/style.css 121 B
build/block-library/blocks/code/theme-rtl.css 124 B
build/block-library/blocks/code/theme.css 124 B
build/block-library/blocks/columns/editor-rtl.css 108 B
build/block-library/blocks/columns/editor.css 108 B
build/block-library/blocks/columns/style-rtl.css 421 B
build/block-library/blocks/columns/style.css 421 B
build/block-library/blocks/comment-author-avatar/editor-rtl.css 125 B
build/block-library/blocks/comment-author-avatar/editor.css 125 B
build/block-library/blocks/comment-content/style-rtl.css 92 B
build/block-library/blocks/comment-content/style.css 92 B
build/block-library/blocks/comment-template/style-rtl.css 199 B
build/block-library/blocks/comment-template/style.css 198 B
build/block-library/blocks/comments-pagination-numbers/editor-rtl.css 123 B
build/block-library/blocks/comments-pagination-numbers/editor.css 121 B
build/block-library/blocks/comments-pagination/editor-rtl.css 222 B
build/block-library/blocks/comments-pagination/editor.css 209 B
build/block-library/blocks/comments-pagination/style-rtl.css 235 B
build/block-library/blocks/comments-pagination/style.css 231 B
build/block-library/blocks/comments-title/editor-rtl.css 75 B
build/block-library/blocks/comments-title/editor.css 75 B
build/block-library/blocks/comments/editor-rtl.css 840 B
build/block-library/blocks/comments/editor.css 839 B
build/block-library/blocks/comments/style-rtl.css 637 B
build/block-library/blocks/comments/style.css 636 B
build/block-library/blocks/cover/editor-rtl.css 647 B
build/block-library/blocks/cover/editor.css 650 B
build/block-library/blocks/cover/style-rtl.css 1.7 kB
build/block-library/blocks/cover/style.css 1.69 kB
build/block-library/blocks/details/editor-rtl.css 65 B
build/block-library/blocks/details/editor.css 65 B
build/block-library/blocks/details/style-rtl.css 98 B
build/block-library/blocks/details/style.css 98 B
build/block-library/blocks/embed/editor-rtl.css 293 B
build/block-library/blocks/embed/editor.css 293 B
build/block-library/blocks/embed/style-rtl.css 410 B
build/block-library/blocks/embed/style.css 410 B
build/block-library/blocks/embed/theme-rtl.css 138 B
build/block-library/blocks/embed/theme.css 138 B
build/block-library/blocks/file/editor-rtl.css 316 B
build/block-library/blocks/file/editor.css 316 B
build/block-library/blocks/file/style-rtl.css 280 B
build/block-library/blocks/file/style.css 281 B
build/block-library/blocks/file/view.min.js 320 B
build/block-library/blocks/footnotes/style-rtl.css 201 B
build/block-library/blocks/footnotes/style.css 199 B
build/block-library/blocks/form-input/editor-rtl.css 229 B
build/block-library/blocks/form-input/editor.css 228 B
build/block-library/blocks/form-input/style-rtl.css 343 B
build/block-library/blocks/form-input/style.css 343 B
build/block-library/blocks/form-submission-notification/editor-rtl.css 343 B
build/block-library/blocks/form-submission-notification/editor.css 342 B
build/block-library/blocks/form-submit-button/style-rtl.css 69 B
build/block-library/blocks/form-submit-button/style.css 69 B
build/block-library/blocks/form/view.min.js 452 B
build/block-library/blocks/freeform/editor-rtl.css 2.61 kB
build/block-library/blocks/freeform/editor.css 2.61 kB
build/block-library/blocks/gallery/editor-rtl.css 957 B
build/block-library/blocks/gallery/editor.css 962 B
build/block-library/blocks/gallery/style-rtl.css 1.55 kB
build/block-library/blocks/gallery/style.css 1.55 kB
build/block-library/blocks/gallery/theme-rtl.css 122 B
build/block-library/blocks/gallery/theme.css 122 B
build/block-library/blocks/group/editor-rtl.css 654 B
build/block-library/blocks/group/editor.css 654 B
build/block-library/blocks/group/style-rtl.css 57 B
build/block-library/blocks/group/style.css 57 B
build/block-library/blocks/group/theme-rtl.css 78 B
build/block-library/blocks/group/theme.css 78 B
build/block-library/blocks/heading/style-rtl.css 189 B
build/block-library/blocks/heading/style.css 189 B
build/block-library/blocks/html/editor-rtl.css 340 B
build/block-library/blocks/html/editor.css 341 B
build/block-library/blocks/image/editor-rtl.css 834 B
build/block-library/blocks/image/editor.css 833 B
build/block-library/blocks/image/style-rtl.css 1.61 kB
build/block-library/blocks/image/style.css 1.6 kB
build/block-library/blocks/image/theme-rtl.css 137 B
build/block-library/blocks/image/theme.css 137 B
build/block-library/blocks/image/view.min.js 2.05 kB
build/block-library/blocks/latest-comments/style-rtl.css 357 B
build/block-library/blocks/latest-comments/style.css 357 B
build/block-library/blocks/latest-posts/editor-rtl.css 213 B
build/block-library/blocks/latest-posts/editor.css 212 B
build/block-library/blocks/latest-posts/style-rtl.css 478 B
build/block-library/blocks/latest-posts/style.css 478 B
build/block-library/blocks/list/style-rtl.css 88 B
build/block-library/blocks/list/style.css 88 B
build/block-library/blocks/media-text/editor-rtl.css 266 B
build/block-library/blocks/media-text/editor.css 263 B
build/block-library/blocks/media-text/style-rtl.css 505 B
build/block-library/blocks/media-text/style.css 503 B
build/block-library/blocks/more/editor-rtl.css 431 B
build/block-library/blocks/more/editor.css 431 B
build/block-library/blocks/navigation-link/editor-rtl.css 671 B
build/block-library/blocks/navigation-link/editor.css 672 B
build/block-library/blocks/navigation-link/style-rtl.css 103 B
build/block-library/blocks/navigation-link/style.css 103 B
build/block-library/blocks/navigation-submenu/editor-rtl.css 299 B
build/block-library/blocks/navigation-submenu/editor.css 299 B
build/block-library/blocks/navigation/editor-rtl.css 2.26 kB
build/block-library/blocks/navigation/editor.css 2.26 kB
build/block-library/blocks/navigation/style-rtl.css 2.27 kB
build/block-library/blocks/navigation/style.css 2.26 kB
build/block-library/blocks/navigation/view.min.js 1.07 kB
build/block-library/blocks/nextpage/editor-rtl.css 395 B
build/block-library/blocks/nextpage/editor.css 395 B
build/block-library/blocks/page-list/editor-rtl.css 401 B
build/block-library/blocks/page-list/editor.css 401 B
build/block-library/blocks/page-list/style-rtl.css 175 B
build/block-library/blocks/page-list/style.css 175 B
build/block-library/blocks/paragraph/editor-rtl.css 235 B
build/block-library/blocks/paragraph/editor.css 235 B
build/block-library/blocks/paragraph/style-rtl.css 335 B
build/block-library/blocks/paragraph/style.css 335 B
build/block-library/blocks/post-author/style-rtl.css 175 B
build/block-library/blocks/post-author/style.css 176 B
build/block-library/blocks/post-comments-form/editor-rtl.css 96 B
build/block-library/blocks/post-comments-form/editor.css 96 B
build/block-library/blocks/post-comments-form/style-rtl.css 508 B
build/block-library/blocks/post-comments-form/style.css 508 B
build/block-library/blocks/post-date/style-rtl.css 61 B
build/block-library/blocks/post-date/style.css 61 B
build/block-library/blocks/post-excerpt/editor-rtl.css 71 B
build/block-library/blocks/post-excerpt/editor.css 71 B
build/block-library/blocks/post-excerpt/style-rtl.css 141 B
build/block-library/blocks/post-excerpt/style.css 141 B
build/block-library/blocks/post-featured-image/editor-rtl.css 666 B
build/block-library/blocks/post-featured-image/editor.css 662 B
build/block-library/blocks/post-featured-image/style-rtl.css 345 B
build/block-library/blocks/post-featured-image/style.css 345 B
build/block-library/blocks/post-navigation-link/style-rtl.css 215 B
build/block-library/blocks/post-navigation-link/style.css 214 B
build/block-library/blocks/post-template/editor-rtl.css 99 B
build/block-library/blocks/post-template/editor.css 98 B
build/block-library/blocks/post-template/style-rtl.css 409 B
build/block-library/blocks/post-template/style.css 408 B
build/block-library/blocks/post-terms/style-rtl.css 96 B
build/block-library/blocks/post-terms/style.css 96 B
build/block-library/blocks/post-time-to-read/style-rtl.css 69 B
build/block-library/blocks/post-time-to-read/style.css 69 B
build/block-library/blocks/post-title/style-rtl.css 100 B
build/block-library/blocks/post-title/style.css 100 B
build/block-library/blocks/preformatted/style-rtl.css 125 B
build/block-library/blocks/preformatted/style.css 125 B
build/block-library/blocks/pullquote/editor-rtl.css 135 B
build/block-library/blocks/pullquote/editor.css 135 B
build/block-library/blocks/pullquote/style-rtl.css 335 B
build/block-library/blocks/pullquote/style.css 335 B
build/block-library/blocks/pullquote/theme-rtl.css 168 B
build/block-library/blocks/pullquote/theme.css 168 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B
build/block-library/blocks/query-pagination-numbers/editor.css 121 B
build/block-library/blocks/query-pagination/editor-rtl.css 221 B
build/block-library/blocks/query-pagination/editor.css 211 B
build/block-library/blocks/query-pagination/style-rtl.css 288 B
build/block-library/blocks/query-pagination/style.css 284 B
build/block-library/blocks/query-title/style-rtl.css 63 B
build/block-library/blocks/query-title/style.css 63 B
build/block-library/blocks/query/editor-rtl.css 486 B
build/block-library/blocks/query/editor.css 486 B
build/block-library/blocks/query/style-rtl.css 312 B
build/block-library/blocks/query/style.css 308 B
build/block-library/blocks/query/view.min.js 637 B
build/block-library/blocks/quote/style-rtl.css 237 B
build/block-library/blocks/quote/style.css 237 B
build/block-library/blocks/quote/theme-rtl.css 223 B
build/block-library/blocks/quote/theme.css 226 B
build/block-library/blocks/read-more/style-rtl.css 140 B
build/block-library/blocks/read-more/style.css 140 B
build/block-library/blocks/rss/editor-rtl.css 149 B
build/block-library/blocks/rss/editor.css 149 B
build/block-library/blocks/rss/style-rtl.css 289 B
build/block-library/blocks/rss/style.css 288 B
build/block-library/blocks/search/editor-rtl.css 184 B
build/block-library/blocks/search/editor.css 184 B
build/block-library/blocks/search/style-rtl.css 613 B
build/block-library/blocks/search/style.css 613 B
build/block-library/blocks/search/theme-rtl.css 114 B
build/block-library/blocks/search/theme.css 114 B
build/block-library/blocks/search/view.min.js 471 B
build/block-library/blocks/separator/editor-rtl.css 146 B
build/block-library/blocks/separator/editor.css 146 B
build/block-library/blocks/separator/style-rtl.css 234 B
build/block-library/blocks/separator/style.css 234 B
build/block-library/blocks/separator/theme-rtl.css 194 B
build/block-library/blocks/separator/theme.css 194 B
build/block-library/blocks/shortcode/editor-rtl.css 329 B
build/block-library/blocks/shortcode/editor.css 329 B
build/block-library/blocks/site-logo/editor-rtl.css 760 B
build/block-library/blocks/site-logo/editor.css 760 B
build/block-library/blocks/site-logo/style-rtl.css 204 B
build/block-library/blocks/site-logo/style.css 204 B
build/block-library/blocks/site-tagline/editor-rtl.css 86 B
build/block-library/blocks/site-tagline/editor.css 86 B
build/block-library/blocks/site-title/editor-rtl.css 116 B
build/block-library/blocks/site-title/editor.css 116 B
build/block-library/blocks/site-title/style-rtl.css 57 B
build/block-library/blocks/site-title/style.css 57 B
build/block-library/blocks/social-link/editor-rtl.css 184 B
build/block-library/blocks/social-link/editor.css 184 B
build/block-library/blocks/social-links/editor-rtl.css 682 B
build/block-library/blocks/social-links/editor.css 681 B
build/block-library/blocks/social-links/style-rtl.css 1.45 kB
build/block-library/blocks/social-links/style.css 1.45 kB
build/block-library/blocks/spacer/editor-rtl.css 359 B
build/block-library/blocks/spacer/editor.css 359 B
build/block-library/blocks/spacer/style-rtl.css 48 B
build/block-library/blocks/spacer/style.css 48 B
build/block-library/blocks/table/editor-rtl.css 432 B
build/block-library/blocks/table/editor.css 432 B
build/block-library/blocks/table/style-rtl.css 646 B
build/block-library/blocks/table/style.css 645 B
build/block-library/blocks/table/theme-rtl.css 157 B
build/block-library/blocks/table/theme.css 157 B
build/block-library/blocks/tag-cloud/style-rtl.css 251 B
build/block-library/blocks/tag-cloud/style.css 253 B
build/block-library/blocks/template-part/editor-rtl.css 403 B
build/block-library/blocks/template-part/editor.css 403 B
build/block-library/blocks/template-part/theme-rtl.css 101 B
build/block-library/blocks/template-part/theme.css 101 B
build/block-library/blocks/term-description/style-rtl.css 111 B
build/block-library/blocks/term-description/style.css 111 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B
build/block-library/blocks/text-columns/editor.css 95 B
build/block-library/blocks/text-columns/style-rtl.css 166 B
build/block-library/blocks/text-columns/style.css 166 B
build/block-library/blocks/verse/style-rtl.css 99 B
build/block-library/blocks/verse/style.css 99 B
build/block-library/blocks/video/editor-rtl.css 552 B
build/block-library/blocks/video/editor.css 555 B
build/block-library/blocks/video/style-rtl.css 191 B
build/block-library/blocks/video/style.css 191 B
build/block-library/blocks/video/theme-rtl.css 139 B
build/block-library/blocks/video/theme.css 139 B
build/block-library/classic-rtl.css 179 B
build/block-library/classic.css 179 B
build/block-library/common-rtl.css 1.11 kB
build/block-library/common.css 1.11 kB
build/block-library/editor-elements-rtl.css 75 B
build/block-library/editor-elements.css 75 B
build/block-library/editor-rtl.css 12.5 kB
build/block-library/editor.css 12.4 kB
build/block-library/elements-rtl.css 54 B
build/block-library/elements.css 54 B
build/block-library/index.min.js 212 kB
build/block-library/reset-rtl.css 472 B
build/block-library/reset.css 472 B
build/block-library/style-rtl.css 14.5 kB
build/block-library/style.css 14.5 kB
build/block-library/theme-rtl.css 700 B
build/block-library/theme.css 705 B
build/block-serialization-default-parser/index.min.js 1.13 kB
build/block-serialization-spec-parser/index.min.js 2.87 kB
build/blocks/index.min.js 51.5 kB
build/commands/index.min.js 15.5 kB
build/commands/style-rtl.css 947 B
build/commands/style.css 942 B
build/components/index.min.js 256 kB
build/components/style-rtl.css 12 kB
build/components/style.css 12 kB
build/compose/index.min.js 12.7 kB
build/core-commands/index.min.js 2.72 kB
build/core-data/index.min.js 72.5 kB
build/customize-widgets/index.min.js 12.1 kB
build/customize-widgets/style-rtl.css 1.43 kB
build/customize-widgets/style.css 1.43 kB
build/data-controls/index.min.js 651 B
build/data/index.min.js 8.87 kB
build/date/index.min.js 17.9 kB
build/deprecated/index.min.js 462 B
build/dom-ready/index.min.js 336 B
build/dom/index.min.js 4.68 kB
build/edit-post/classic-rtl.css 571 B
build/edit-post/classic.css 571 B
build/edit-post/index.min.js 35.8 kB
build/edit-post/style-rtl.css 7.58 kB
build/edit-post/style.css 7.57 kB
build/edit-site/index.min.js 208 kB
build/edit-site/style-rtl.css 14.4 kB
build/edit-site/style.css 14.4 kB
build/edit-widgets/index.min.js 17.2 kB
build/edit-widgets/style-rtl.css 4.65 kB
build/edit-widgets/style.css 4.65 kB
build/editor/index.min.js 47.4 kB
build/editor/style-rtl.css 3.74 kB
build/editor/style.css 3.73 kB
build/element/index.min.js 4.87 kB
build/escape-html/index.min.js 548 B
build/format-library/index.min.js 7.76 kB
build/format-library/style-rtl.css 577 B
build/format-library/style.css 577 B
build/hooks/index.min.js 1.57 kB
build/html-entities/index.min.js 454 B
build/i18n/index.min.js 3.61 kB
build/interactivity/index.min.js 11.4 kB
build/is-shallow-equal/index.min.js 535 B
build/keyboard-shortcuts/index.min.js 1.76 kB
build/keycodes/index.min.js 1.9 kB
build/list-reusable-blocks/index.min.js 2.11 kB
build/list-reusable-blocks/style-rtl.css 865 B
build/list-reusable-blocks/style.css 865 B
build/media-utils/index.min.js 2.92 kB
build/notices/index.min.js 964 B
build/nux/index.min.js 2.01 kB
build/nux/style-rtl.css 775 B
build/nux/style.css 771 B
build/patterns/index.min.js 4.84 kB
build/patterns/style-rtl.css 564 B
build/patterns/style.css 564 B
build/plugins/index.min.js 1.81 kB
build/preferences-persistence/index.min.js 1.85 kB
build/preferences/index.min.js 1.26 kB
build/primitives/index.min.js 994 B
build/priority-queue/index.min.js 1.52 kB
build/private-apis/index.min.js 988 B
build/react-i18n/index.min.js 631 B
build/react-refresh-entry/index.min.js 9.46 kB
build/react-refresh-runtime/index.min.js 6.78 kB
build/redux-routine/index.min.js 2.71 kB
build/reusable-blocks/index.min.js 2.74 kB
build/reusable-blocks/style-rtl.css 265 B
build/reusable-blocks/style.css 265 B
build/rich-text/index.min.js 9.97 kB
build/router/index.min.js 1.79 kB
build/server-side-render/index.min.js 1.96 kB
build/shortcode/index.min.js 1.4 kB
build/style-engine/index.min.js 1.98 kB
build/token-list/index.min.js 587 B
build/url/index.min.js 3.83 kB
build/vendors/inert-polyfill.min.js 2.48 kB
build/vendors/react-dom.min.js 41.8 kB
build/vendors/react.min.js 4.02 kB
build/viewport/index.min.js 967 B
build/warning/index.min.js 259 B
build/widgets/index.min.js 7.18 kB
build/widgets/style-rtl.css 1.18 kB
build/widgets/style.css 1.18 kB
build/wordcount/index.min.js 1.03 kB

compressed-size-action

@tellthemachines tellthemachines added the Needs PHP backport Needs PHP backport to Core label Nov 17, 2023
Comment on lines 165 to +170
const {
allowSwitching,
allowEditing = allowEditingSetting ?? true,
allowEditing = true,
allowInheriting = true,
default: defaultBlockLayout,
} = layoutBlockSupport;
} = blockSupportAndThemeSettings;
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this changes the logic slightly in that layoutBlockSupport now always overrides layoutSettings and so setting allowEditing in theme.json will no longer override the block.json setting?

Is it possible to do something like:

  • Grab the block level (block.json) settings
  • Iterate over the desired theme.json settings and if they're set to false, apply them over the block.json settings

That way if allowCustomContentSize is explicitly set to true in block.json but theme.json sets it to false, the latter wins. But if they're set the other way around block.json wins (essentially, false always wins).

Just a quick thought, though, happy to give this PR a more thorough review next week! 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that's what I was referring to in my previous comment! In principle, none of those settings should be explicitly enabled as their defaults are always true, and this will work as it is for all core blocks. Of course there's no way to control what third party block providers do with their settings, so e.g. a theme that disables controls at a global level won't be able to override a hypothetical custom block that explicitly enables settings. I don't see that as a huge issue though.

There's also the slight problem of contentSize and wideSize being set to false for all blocks in the settings. Though it's unlikely that a block would set them explicitly in its block.json, that's not something we'd want to override if it were set.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for clarifying!

Copy link
Contributor

@andrewserong andrewserong Nov 20, 2023

Choose a reason for hiding this comment

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

I was a little confused by the false value for contentSize and wideSize, and I think I might have gone down a rabbithole 😄

From looking where it's set (here), I think I see why that's happening as a default now. It seems the assumption in useSettingsForBlockElement might have been that contentSize and wideSize would work similarly to other settings in that they'd be explicitly opted into. So they default to false in that hook, but a block might set either of these to true in block.json.

I was going to say, what if we used contentSize and wideSize as the boolean flag to show / hide the controls instead of allowCustomContentSize, but I'm not sure that would work because we already use these props at the root level to define the value of these fields instead of their visibility status. It's a bit unfortunate, because looking at it now, I wonder if it'd have made sense to have contentSize and wideSize as values under styles and to keep the boolean status in settings so that it'd match how padding/margin works?

At any rate, keeping a separate allowCustomContentSize prop (or allowContentSize, whichever naming works) sounds like the pragmatic path forward to me.

In terms of the issue of expanding values and passing them down via the layoutBlockSupport prop on layoutType.inspectorControls, would it be safer to merge just the values that we want to grab from settings for now? So similar to how it previously did allowEditing = allowEditingSetting ?? true, we might construct it something like:

	const blockSupportAndThemeSettings = {
		...layoutBlockSupport,
		allowEditing: layoutSettings.allowEditing ?? true,
		allowCustomContentSize: layoutSettings.allowCustomContentSize ?? true,
	};

I haven't tried that out, so just an idea! And apologies if I'm overthinking it, I got quite lost looking up those default false values 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That could work! We'll potentially have to do the same for all the other allow... settings. I guess there's not that many of them so it's not a huge issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand correctly, that's essentially what my previous code was doing; might as well revert the commit.

It's pretty close, but from re-testing, two things that aren't covered in the previous state are:

  • If a value is explictly set to true in block.json, it can't be overridden by theme.json
  • If we wish to exclude other values in layoutSettings that we don't want to pass down (like the false values for contentSize and wideSize)

Would it be better for consistency with other blocks supports to allow theme.json to override true values, where for example if spacing.padding is set to true in block.json, then it can still be overridden by theme.json?

I'd like to avoid iterating over specific settings if possible.

How come? I was thinking it could be good to be specific about the settings so that we know which ones are handled, otherwise it might be unexpected if or when someone goes to add additional properties that might expect different behaviour 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like to avoid the iteration in order to keep the logic clear and ensure existing settings such as allowJustification or allowOrientation can be enabled just by adding them to VALID_SETTINGS (which I was planning to do in a follow-up PR)

Also, ideally the order of things should be predictable and not vary per setting; in this case, it seems best for block.json to override theme.json settings so that blocks that disable controls aren't overridden. In my mind it would be unexpected if different orders were applied to different settings.

If a value is explictly set to true in block.json, it can't be overridden by theme.json

Core blocks never explicitly set these values to true, and I wouldn't expect most custom blocks to do so either (this can be clarified in documentation to help extenders make good decisions, but regardless, if custom block authors really want controls to always be available then I'd say that's up to them, because they always have the option to create their own controls if core ones don't do what they want)

If we wish to exclude other values in layoutSettings that we don't want to pass down (like the false values for contentSize and wideSize)

contentSize and wideSize ending up in this layout settings object shouldn't affect anything as we're not using them at all, unless I'm missing something! The only place this object is being used is in the layout inspector controls.

Copy link
Contributor

@andrewserong andrewserong Nov 21, 2023

Choose a reason for hiding this comment

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

Okay, great, thanks for thinking this through with me! That all sounds reasonable to me, especially once we document it, and it certainly is more readable the way that you've done it 👍

I suppose the last question then is that pesky naming question of what we call the setting 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😅

I honestly don't have any better ideas, especially given the other layout controls all follow the same pattern. And Lightbox support is also using allowEditing as of 6.4.

Copy link
Contributor

Choose a reason for hiding this comment

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

Me either. I don't feel strongly about the naming, but I'd personally lean toward either allowCustomContentSize or allowContentSize since we have that prefix for the other layout controls, as you mention, and we likely want parity between what block.json uses and what theme.json uses. The thing that I like about allow as a prefix is that it's clearer it's about what's exposed in the UI, rather than what's output. I think the layout support is possibly a bit unique in this respect, where it can be helpful to have that extra clarity.

Also, the word custom in allowCustomContentSize is good, because we're still allowing a user to switch between flow and constrained layout types, where content size is output via the default layout styles... so of all the available options so far, I think allowCustomContentSize is my favourite.

@carolinan
Copy link
Contributor

Can we remove "allow" from allowCustomContentSize? The other settings use these names:

customDuotone
customGradient
customSpacingSize
customFontSize

@tellthemachines
Copy link
Contributor Author

Can we remove "allow" from allowCustomContentSize? The other settings use these names:

@carolinan all the layout properties use "allow". The difference from the other settings you mention is that these layout settings don't disable the functionality itself, but only the user-facing controls. So a block with allowCustomContentSize set to false won't display the controls, but it's still possible to set a custom size in the block attributes by editing the markup, and it will be respected.

@carolinan
Copy link
Contributor

I don't think that intention is clear. Not by the name, or by how it works. If I add "customFontSize":false, but add this to the markup, the block uses the value I set correctly, without block validation errors or similar:

<!-- wp:paragraph {"style":{"typography":{"fontSize":"3rem"}}} -->
<p style="font-size:3rem">A paragraph</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"style":{"typography":{"fontSize":"8px"}}} -->
<p style="font-size:8px">A paragraph</p>
<!-- /wp:paragraph -->

Copy link
Contributor

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

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

This is testing quite well for me, thanks again for the discussion here:

✅ Setting allowCustomContentSize at the root layout object allows globally hiding the controls
✅ Setting the allowCustomContentSize value at the block level in theme.json allows you to override the global value (so you can show everywhere except Group block, or hide everywhere except Cover block, for example)

I was curious about the naming, too — I don't have a strong opinion about it, but I wondered briefly if we could just use contentSize and wideSize instead of an additional prop prefixed via allow. Unfortunately, because of how we set content/wideSize to a pixel value in the root layout object, I don't think that's possible, but I left a comment with where I got to in investigating.

Whichever naming convention we go with, my main opinion is that we pick something we're happy sticking with, whichever name that might be 🙂

Comment on lines 165 to +170
const {
allowSwitching,
allowEditing = allowEditingSetting ?? true,
allowEditing = true,
allowInheriting = true,
default: defaultBlockLayout,
} = layoutBlockSupport;
} = blockSupportAndThemeSettings;
Copy link
Contributor

@andrewserong andrewserong Nov 20, 2023

Choose a reason for hiding this comment

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

I was a little confused by the false value for contentSize and wideSize, and I think I might have gone down a rabbithole 😄

From looking where it's set (here), I think I see why that's happening as a default now. It seems the assumption in useSettingsForBlockElement might have been that contentSize and wideSize would work similarly to other settings in that they'd be explicitly opted into. So they default to false in that hook, but a block might set either of these to true in block.json.

I was going to say, what if we used contentSize and wideSize as the boolean flag to show / hide the controls instead of allowCustomContentSize, but I'm not sure that would work because we already use these props at the root level to define the value of these fields instead of their visibility status. It's a bit unfortunate, because looking at it now, I wonder if it'd have made sense to have contentSize and wideSize as values under styles and to keep the boolean status in settings so that it'd match how padding/margin works?

At any rate, keeping a separate allowCustomContentSize prop (or allowContentSize, whichever naming works) sounds like the pragmatic path forward to me.

In terms of the issue of expanding values and passing them down via the layoutBlockSupport prop on layoutType.inspectorControls, would it be safer to merge just the values that we want to grab from settings for now? So similar to how it previously did allowEditing = allowEditingSetting ?? true, we might construct it something like:

	const blockSupportAndThemeSettings = {
		...layoutBlockSupport,
		allowEditing: layoutSettings.allowEditing ?? true,
		allowCustomContentSize: layoutSettings.allowCustomContentSize ?? true,
	};

I haven't tried that out, so just an idea! And apologies if I'm overthinking it, I got quite lost looking up those default false values 😅

@tellthemachines
Copy link
Contributor Author

I don't think that intention is clear. Not by the name, or by how it works.

The earliest settings with that name were added in #34194, so I think that ship has sailed. We could rename them, but we'll still have to provide support for the existing ones indefinitely.

Also, naming things clearly is hard. What could we call these settings alternatively?

If I add "customFontSize":false, but add this to the markup, the block uses the value I set correctly, without block validation errors or similar

Oh I hadn't realised you could do that. Still, you wouldn't be able to set a custom font size in theme.json and disable the control for a particular block, whereas with the existing layout settings we can e.g. set justification for a block and also disable the justification controls. I'm not sure how widely used that might be, but it's how all the layout controls work so far (the only ones that don't have the allow... off switch yet are contentSize and the Grid layout controls)

Copy link

github-actions bot commented Nov 21, 2023

Flaky tests detected in 53061ef.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6938635943
📝 Reported issues:

Copy link
Contributor

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

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

I just noticed while testing that there's also a JS version of the VALID_SETTINGS constant:

We're not exposing updating the allowCustomContentSize property anywhere in the UI, but should it also be in that array? I wasn't too sure.

@tellthemachines
Copy link
Contributor Author

We're not exposing updating the allowCustomContentSize property anywhere in the UI, but should it also be in that array? I wasn't too sure.

That's a good question, I'm not sure either. There doesn't seem to be a 1:1 match between properties on those two arrays - the JS one has layout.definitions for instance, and the PHP one has layout.allowEditing. It might be better to look into it separately, and see if it's worth syncing them? Or else if we should make it clearer that they aren't meant to match 😅

Copy link
Contributor

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

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

The shape of this PR is looking good to me, and the behaviour is working correctly for me as we discussed in the comments 👍

It seems like the final question is about the naming of the property. I personally quite like allowCustomContentSize as it follows the structure of the other boolean layout properties, but it might be worth getting a second opinion as it could be difficult to change the name after the fact if we want to, and since @carolinan had some concerns about the clarity of the name.

I'll just ping @WordPress/gutenberg-core in case anyone has strong opinions about it. I seem to recall having discussions with @oandregal about naming of theme.json properties in the past 🙂

@ramonjd
Copy link
Member

ramonjd commented Nov 23, 2023

I personally quite like allowCustomContentSize as it follows the structure of the other boolean layout properties,

+1

The flag determines UI control visibility, and doesn't described a specific value or property so I think it's generic enough to handle iterations to the control itself.

Also layout.contentSize and wideSize use "size" and not "width", so it seems consistent to me.

Just my 1.99 cents

@scruffian
Copy link
Contributor

One thing I have been wondering about controls like this - do we want them at a theme level or a site level? The way I see it, the job of theme.json is to define the visual appearance of a site. I wonder if settings like this are more aimed at situations where a developer wants to lock down access to certain features on a site. If that is the case maybe it makes more sense for these settings to live in a different configuration (maybe site.json). This would have the advantage of staying in place even if a user switches theme, and allowing theme.json to be used solely for the purpose of controlling a site's visual appearance.

@t-hamano
Copy link
Contributor

It seems like the final question is about the naming of the property.

I also prefer the name allowCustomContentSize, but my only concern is that there might be use cases in the future where we only want to disable either content size or wide size. In that case, a name like allowCustomSize might be an idea.

In other words, I'm considering the following possibilities in the future.

  • allowCustomSize: Disable content width and wide width
  • allowCustomContentSize: Disable content width only
  • allowCustomWideSize: Disable wide width only

@oandregal
Copy link
Member

I'll just ping @WordPress/gutenberg-core in case anyone has strong opinions about it. I seem to recall having discussions with @oandregal about naming of theme.json properties in the past 🙂

Naming, right? I reckon I have my weaknesses 😆

Quickly glanced through the conversation and the existing theme.json settings. I see layout already uses allow* as lightbox does as well – so that's coherent with using allow* here as well.

Another point is that it seems custom* is more for when the user wants to select a custom value, not a preset one. Whereas this setting is more about whether the UI is visible?

That's more or less how would I think about this topic. Though whatever you feel right is good 🙂

@andrewserong
Copy link
Contributor

Good discussion, folks!

do we want them at a theme level or a site level? The way I see it, the job of theme.json is to define the visual appearance of a site. I wonder if settings like this are more aimed at situations where a developer wants to lock down access to certain features on a site

That's a good question — I suppose one way to look at it is that it should be possible for a theme to lock down the visual controls and also for a site owner to be able to do so. The former case is about which controls are exposed in the UI, so while UI controls are hidden, it's not really defining access controls in that block markup with particular values can still be used. The latter case I could imagine being a fair bit more complex: if we're trying to prevent users from being able to make certain kinds of changes, then folks might want stricter protections on preventing block markup with certain features, so we might also need another level of validation on block markup?

This would have the advantage of staying in place even if a user switches theme, and allowing theme.json to be used solely for the purpose of controlling a site's visual appearance.

Folks are already using theme.json to define which settings are visible via opting in or opting out of particular controls, so I imagine we'll need to continue to support it in theme.json even if we also expose a site.json settings object in the future. So, in that case, I think the question probably comes back to whether we like the shape of layout.allowCustomContentSize as the name, as I assume we'd likely go with the same name across block.json, theme.json and a potential site.json in the future 🤔

@tellthemachines
Copy link
Contributor Author

Thanks for the feedback folks!

there might be use cases in the future where we only want to disable either content size or wide size.

I'm not convinced there'll ever be a use case for keeping either content or wide size editable without the other. We could perhaps go with allowCustomContentAndWideSize to make it more explicit but it's a bit of a mouthful.

@tellthemachines
Copy link
Contributor Author

One thing I have been wondering about controls like this - do we want them at a theme level or a site level? The way I see it, the job of theme.json is to define the visual appearance of a site. I wonder if settings like this are more aimed at situations where a developer wants to lock down access to certain features on a site.

If the developer is the theme author, it makes sense for these settings to continue in theme.json. I'm considering the ability to change certain visual features as part of the definition of the visual appearance of the site. If we think of theme.json as a sort of style guide, then ability to edit settings does have a place in there.

Locking down features at a site level would give control of these choices to site admins instead of developers, which I'm unsure is what we want here. It might be worth researching some use cases here - I think agencies would be able to give us some good feedback on what's most useful.

I imagine we'll need to continue to support it in theme.json even if we also expose a site.json settings object in the future

Correct; disabling layout controls overall is already available in theme.json since WP 6.4 so removing support is no longer an option. Given the global setting exists, it also makes sense to provide individual settings.

@tellthemachines
Copy link
Contributor Author

Ok; updated the setting name to allowCustomContentAndWideSize and rebased the branch to get the latest CI changes.

@andrewserong
Copy link
Contributor

Ok; updated the setting name to allowCustomContentAndWideSize and rebased the branch to get the latest CI changes.

Looking good! Apologies for one last naming suggestion, but just looking over this again, and wondered if allowCustomSizes could group together the general ideas, while shortening the name? I don't feel strongly about it, though, and while allowCustomContentAndWideSize is a mouthful, it has the benefit of clarity 👍

@tellthemachines
Copy link
Contributor Author

wondered if allowCustomSizes could group together the general ideas, while shortening the name?

Yeah sorry I didn't explain my whole reasoning above. allowCustomSizes isn't clear about what it does, and will be confusing especially once other size-related layout controls get built, for grid columns and spans for instance (not to mention the already existing flexSize child attribute)

Copy link
Contributor

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

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

Thanks for all the back and forth here and for the explanation! This is all testing well for me, and I think we've settled on a good name factoring in all the trade-offs 👍

✅ In theme.json, can set layout.allowCustomContentAndWideSize to false to disable controls across all blocks
✅ In theme.json, can set layout.allowCustomContentAndWideSize to true to enable controls for a single block as an exception
✅ Can disable at the block level in block.json by setting it to false

I've just updated the example in the PR description to reflect the new name for the prop.

LGTM! ✨

@tellthemachines tellthemachines merged commit 1c835dd into trunk Nov 28, 2023
52 checks passed
@tellthemachines tellthemachines deleted the add/allow-content-size branch November 28, 2023 04:28
@github-actions github-actions bot added this to the Gutenberg 17.2 milestone Nov 28, 2023
@scruffian
Copy link
Contributor

If the developer is the theme author, it makes sense for these settings to continue in theme.json. I'm considering the ability to change certain visual features as part of the definition of the visual appearance of the site. If we think of theme.json as a sort of style guide, then ability to edit settings does have a place in there.

The reason for my hesitance here is that the way I see it, theme.json files should only be concerned with the visual appearance of a site, not other configuration settings. I know that we already have other settings in theme.json that don't fit with this model (for example templates) but I just wanted to share where I think we should be moving towards. That shouldn't block this work, but just wanted to raise it as something to keep in mind for the future :)

@tellthemachines
Copy link
Contributor Author

theme.json files should only be concerned with the visual appearance of a site, not other configuration settings

Isn't the configurability of the visual appearance a visual appearance concern though? Or do you reckon that theme.json should only contain settings that translate directly to CSS?

I'm not sure to what extent changing the current approach of styles + settings will be possible given we'll have to continue supporting it forever. Conceptually, I'm not super invested either way 😄 but I do think it's important to be clear on who should be responsible for the decision to expose these controls or not.

To me it makes sense that any controls related to appearance should be defined by the theme author as part of the theme, so if it's not in theme.json it should be in another theme file. An argument could also be made for site admins to own these settings, or for both: site config could exist on top of theme config.

derekblank pushed a commit that referenced this pull request Dec 7, 2023
* Add setting to disable custom content size controls

* Make sure theme setting overrides block setting.

* Revert "Make sure theme setting overrides block setting."

This reverts commit ad4b76c.

* Change setting name to `allowCustomContentAndWideSize`
@tellthemachines tellthemachines removed the Needs PHP backport Needs PHP backport to Core label Jan 8, 2024
@tellthemachines
Copy link
Contributor Author

Dev note:

Setting to disable custom content size controls

Similar to the setting that allows disabling layout controls in WP 6.4, this allows only the content and wide size controls for constrained layout to be disabled from theme.json, globally or at a per-block level .

To disable for all blocks globally, add the following in theme.json under settings.layout:

"allowCustomContentAndWideSize": false

To disable at the block level, add the following in theme.json under settings.blocks:

"core/group": {
	"layout": {
		"allowCustomContentAndWideSize": false
	}
}

@tellthemachines tellthemachines added the has dev note when dev note is done (for upcoming WordPress release) label Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Layout Layout block support, its UI controls, and style output. has dev note when dev note is done (for upcoming WordPress release) [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants