-
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
'align' support flag - add server side block support for block alignment. #24122
'align' support flag - add server side block support for block alignment. #24122
Conversation
Size Change: -16 B (0%) Total Size: 1.15 MB
ℹ️ View Unchanged
|
Is conditionally wrapping the template part the right way to handle alignments? I can't think of a better way, but I'm just making sure, since I can't recall if any solid direction has been chosen yet as a result of the discussion in #20650. |
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.
Tested and confirmed that I see alignfull
rendered in the front end. 👍 I think there will need to be the wrapper to apply top level classnames like this, otherwise there is nowhere for them to go.
I feel like it needs a wrapper regardless. In the future this wrapper should be a semantic element specified by an attribute saved for that template part block (instead of Stepping back to talk about alignments specifically - this PR is specific to the |
Or worse, without the wrapper on the Template Part the classname was being added to the first interior block of the template part instead. This was also causing some odd nesting within that first interior block and rendering different sections of the page on top of each other. |
Im not sure why the |
I figured it was a bug fix PR since the alignment controls were already being shown but not actually doing anything. I guess it's sort of both an enhancement and a bug fix? |
Ah gotcha, that makes sense. TBH, I think most of the blocks that this will end up supporting don't have the alignment flag added yet. Looking further it seems both the "Template Part" and "Post Content" blocks were given the flag back when wide alignment support was added to the site editor #23488, but since that was all tested regarding wide support inside the site editor itself we must have missed that it wasn't being added on the front-end (although its expected that it wouldn't be since both of those blocks require the render callback). |
@youknowriad - would you mind giving this a glance here when you get a chance? Re expanding on #23007 to add support for the |
It seems good at a glance. I didn't check but I think there's probably a bunch of existing dynamic blocks where you could remove code from (align applied ad-hoc ). |
It looks like the following blocks fit this case:
I will create a follow up to remove the unnecessary code for these. (created #24223) |
Description
Expanding on #23007 - Updates the
gutenberg_experimental_apply_classnames_and_styles
function inlib/blocks.php
to apply block alignment classnames for blocks that support thealign
flag and depend on a render callback.This also adds a wrapper to the Template Part block on the front end. This block was previously given the
align
support flag to have block alignment work in the editor, but was never updated for the front-end. Since there was no wrapper for this block on the front-end, the classes were being added to the first child of the template part block instead and causing other issues with blocks nesting under that first child.How has this been tested?
Tested on local docker environment.
This can be tested with the template part block:
alignfull
class is added to the wrapper div.Screenshots
Types of changes
New feature (non-breaking change which adds functionality)
Checklist: