-
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
Move layout custom properties to filter. #37438
Conversation
Size Change: +186 B (0%) Total Size: 1.13 MB
ℹ️ View Unchanged
|
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 following-up with this, this is very good I think.
} | ||
} | ||
$style .= '}'; | ||
|
||
$style .= "$selector > * { margin: 0; }"; | ||
} | ||
|
||
return $style; | ||
return apply_filters( 'layout_styles', $style, $selector, $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.
Do we need extra filters (aka new APIs to support)? Can't we rely on render_block
for the backend and editor.BlockListBlock
for the frontend?
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.
Also potentially we don't need any filter, we can just add the logic to the "render_callback" of the navigation block in the backend and to "edit" function of the navigation block in the frontend?
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.
render_block
and editor.BlockListBlock
won't work because we can't get the layout properties from them. Would it help to name the filter __unstable
while we figure out what works best in terms of API? Or is that naming convention not applicable to filters?
Also potentially we don't need any filter, we can just add the logic to the "render_callback" of the navigation block in the backend and to "edit" function of the navigation block in the frontend?
We could do something along these lines, but if we want to keep all the logic in the Nav block it might be easier (and cleaner) to just output all the items-justified-
etc. classnames and hook the CSS off those.
Nice one. From just a quick test, layout properties appear to work as they should, both inside and outside of the modal, and in both horizontal and vertical orientations, as shown in this GIF: In being a mostly under the hood change, I imagine #36778 would also work as-is? I'll defer to Riad on a green light, but hopefully the testing was useful. |
@jasmussen whatever happens here shouldn't make a difference to #36778. The idea is to output exactly the same styles, it's how we generate and attach them that is changing. |
I just tried something different in #37473. |
Closing this in favour of #37473. |
Description
Follow-up from this discussion. Moves the custom properties optionally added to layout with
setCascadingProperties
to a custom filter in the Navigation block.How has this been tested?
Create a Navigation block; change justification/orientation and verify everything works as expected in both editor and front end.
Screenshots
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist:
*.native.js
files for terms that need renaming or removal).