-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Post Content: Ensure layout classnames are applied in readonly preview #53864
Post Content: Ensure layout classnames are applied in readonly preview #53864
Conversation
Size Change: -5 B (0%) Total Size: 1.51 MB
ℹ️ View Unchanged
|
Flaky tests detected in 5db52f1. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5935646834
|
@@ -147,7 +152,10 @@ export default function PostContentEdit( { | |||
return ( | |||
<RecursionProvider uniqueId={ contextPostId }> | |||
{ contextPostId && contextPostType ? ( | |||
<Content context={ context } layout={ layout } /> |
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.
Note: the removal of passing down layout
is safe, as the usage of the passed down prop was removed in #47477 — for the EditableContent
state of the Post Content block, the layout classnames are already handled by useInnerBlocksProps
.
5db52f1
to
f0bec3b
Compare
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 fixing this! Changes LGTM; testing shows Post Content now has the correct layout classes applied when inside Post Template and still works as expected elsewhere.
Thanks for reviewing @tellthemachines! 🙇 I'll merge this in now. |
What?
Fixes #53752
Ensure that layout classnames are output for the readonly preview of the Post Content block by passing them in to
useBlockProps
.Why?
The Placeholder state already uses these layout classnames, and the editable view should already be getting the layout classnames via
useInnerBlocksProps
. Because the read only preview is a bit of a special case, we need to manually pass the layout classnames in order for them to be applied to the preview. (The preview / read only state does not useuseInnerBlocksProps
so does not receive layout classnames automatically without wiring them up like in this PR).How?
edit.js
so that the layout classnames are passed down to and output for the read only content state of the block.layout
prop being passed toContent
as it was a leftover after Always pass layout to inner blocks #47477 landed.Testing Instructions
In a site's home template, at the following at the root level to add a Query Loop block where the Content block within Post Template is set to use constrained layout:
Query Loop markup
Then, add a post containing a few blocks, one at content width, one at wide width, and one at full-wide width. For example, here's a few cover blocks:
Cover block markup
trunk
the post will display in the site editor's content preview as full width, with no spacing between blocks, due to the lack of layout classnames being output.Inner blocks use content width
at the Content block level should update and reflect in the site editor, along with any custom values entered forContent
andWide
sizes.Screenshots or screencast
Before
After