-
Notifications
You must be signed in to change notification settings - Fork 21
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 align support in block themes #136
Conversation
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.
All good.
What was the solution to this? I'm also running into an issue when I have theme.json and add_theme_support( 'align-wide' ); with the align wide and full options not appearing in the editor. |
I'm still seeing this issue as well. |
The theme.json overrides features added via add_theme_support(). This is known and ok. But strangely the theme.json overwrites also the function "align-wide" although this is not defined in the schema or can't be configured there at all. The problem lies in the merging of the settings. The error is in the function "get_theme_data()" in the "WP_Theme_JSON_Resolver" class -> https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-theme-json-resolver.php#L195 where "Theme Support" settings are mapped to the SCHEMA. So "align-wide" and possibly other features are simply removed here. Long story short -> you have to define minimum "contentSize" child attribute of "layout" in theme.json to display the "Full width" button in Align... |
This problem reappeared in Gutenberg version 15.1.0
Create a new page and insert a cover block and you have the align wide/full controls, then add a basic theme.json with only this content: |
@Zsolt-R: +1, same issue again with latest Gutenberg! |
Closes #87
Previously we were checking
get_theme_support( 'align-wide' )
to see if we should include the wide/full alignment options in the Container block.However, block-based themes don't use
add_theme_support()
(https://fullsiteediting.com/lessons/global-styles/#h-layout-and-content-width), so this check was failing for them.This PR ditches the
get_theme_support()
check and usesgetBlockSupport()
(https://github.com/WordPress/gutenberg/blob/1da217e8a57803e2c9183316cdef3d09c618ffcb/packages/blocks/src/store/selectors.js#L264) with an empty block name andtrue
as the default value. This seems to allow us to artificially set support foralign
to true only when we need it.It should:
add_theme_support()
(GeneratePress)add_theme_support( 'align-wide' )
is not setlayout
options aren't set in theme.json: https://github.com/WordPress/theme-experiments/blob/master/tt1-blocks/theme.json#L111-L114It would obviously be easier if we could set the
align
supports option to true in block registration, but then we would: