-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Block editor: hooks: useBlockProps for layout #57084
Conversation
Size Change: -65 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
f3d0217
to
2536be9
Compare
Flaky tests detected in 2536be9. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7215274762
|
This is so that the layout classnames can be applied manually in the block edit function if needed; a few of the core blocks with custom layout logic are using them. Some of them maybe could be refactored but each block is its own case and would need looking at separately. We'd also need to work out if
|
@@ -516,6 +516,16 @@ export function createBlockListBlockFilter( features ) { | |||
<BlockListBlock | |||
key="edit" | |||
{ ...props } | |||
__unstableLayoutClassNames={ allWrapperProps |
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.
This won't always be rendered because some blocks are returning early above when they don't have set values in their attributes. You can test this by inserting a Gallery and a Navigation block on a page: they won't have their proper layout because the layout classnames aren't being output.
Layout always outputs default styles, even if no attributes are set on the block. The styles are output based on the default layout type declared in the block.json. You only get layout related attributes explicitly declared on the block if you change the default settings for a layout type, e.g. change the justification or orientation on a flex block.
So I think for this to work the logic above should maybe check only what the block supports instead of its explicit attributes.
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.
What?
I skipped this one because it had some odd things: it passes
__unstableLayoutClassNames
toBlockListBlock
instead of wrapper props. I wonder if we can refactor this in the future. It also relies on the style attribute... not sure why.Why?
This is the last
BlockListBlock
to be removed. Also removes auseSelect
call per block, since it was unguarded.How?
Testing Instructions
I have no idea how to test this so would appreciate any help 😃
Testing Instructions for Keyboard
Screenshots or screencast