-
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
Layout: Always add semantic classes #60668
Conversation
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. |
Size Change: +845 B (0%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
Tested and fixed the layout issue described above. My testing steps:
|
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 the PR! This fixes the issue for me ✅
Tested on classic and block themes with layout styles enabled and disabled. Classnames are correctly output in all cases.
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.
+1 this is testing great for me, too. Thanks for the follow-up! ✨
I just spotted something weird in this PR branch: the Page List block is getting layout classnames when it shouldn't. Seems to be the only block without layout support to get the classnames. Trying to work out why now 😅 |
layoutClasses.length > 0 ? layoutClasses : undefined | ||
} | ||
/> | ||
); |
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.
The problem seems to be that useLayoutClasses
doesn't actually check if the block supports layout in order to output the classes (which is fine, that's not its role), so here, we're always passing in layout classes, whether the block supports layout or not. I think the check here should be blockSupportsLayout ? layoutClasses : undefined
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.
Oh, good catch!
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.
For posterity: the unwanted layout classes were appearing on Page List because it uses innerBlocksProps
, where those classnames are retrieved from the block edit context and added to the inner blocks wrapper. So this would happen on any block with inner blocks and without layout support.
Could we please add an e2e test? 🙂 |
Hi, thanks for this PR, this fixes the issue for me ✅ Themes with |
@ellatrix, I can follow-up with e2e tests, but unfortunately not today :( |
Flaky tests detected in 36d8c2c. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/8660225514
|
I'm going to merge this and will follow-up with e2e tests ASAP. |
* Layout: Always add semantic classes * Default to undefined * Feedback Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org> Co-authored-by: colorful-tones <colorful-tones@git.wordpress.org> Co-authored-by: ellatrix <ellatrix@git.wordpress.org> Co-authored-by: davecpage <davecpage@git.wordpress.org>
I manually cherry-picked this PR to the |
* Layout: Always add semantic classes * Default to undefined * Feedback Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org> Co-authored-by: colorful-tones <colorful-tones@git.wordpress.org> Co-authored-by: ellatrix <ellatrix@git.wordpress.org> Co-authored-by: davecpage <davecpage@git.wordpress.org>
What?
Fixes #60569.
PR fixes a missing semantic layout classes regression in the editor.
Why?
Matches behavior described in docs: https://developer.wordpress.org/block-editor/explanations/architecture/styles/#opting-out-of-generated-layout-styles.
Notes
useLayoutClasses
is a privately exported hook used inReusableBlockEdit
andEditorCanvas
.Testing Instructions
is-layout-constrained
.Testing snippet
Testing Instructions for Keyboard
Same.
Screenshots or screencast