-
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
Fix Site Logo block alignment issues #36627
Conversation
Front, markup without the PR:Default, no alignment: Centered: I do not see the Front, markup with the PRDefault, no alignment: Centered: |
@carolinan I apologize for any confusion. I should have outlined the steps more clearly. Issue 1: Issue 2: Issue 3: Related issue A: Let me know if I can answer any additional questions or you find any other issues! |
As far as I can tell, the PR solves the issues, but it needs a retest with the column or cover block. |
I have added the backport tag as I really believe we need to get a solution in place prior to 5.9 Beta 1. Without a fix, it's nearly impossible to configure certain header layouts in an FSE theme. |
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.
Nice work @ndiego 👍
Alignments, in general, are a bit rough but in my testing, this PR does improve them for the Site Logo block.
✅ Alignments (except right-alignment with Columns) were consistent between editor and frontend
✅ Alignments were consistent regardless of current theme type (Block or Classic)
✅ No duplicate alignment classes in markup
Tested with:
- TwentyTwentyTwo
- TT1 Blocks
- Emptytheme
- TwentyTwentyOne
- TwentyTwenty
However when aligned right while placed in another block, the Site Logo will not align right in the Block Editor, but will appear aligned right on the frontend.
As you note in #36624, when within a Columns block the aligned block wrapper doesn't receive the float: right
style. I believe this could be due to the Columns block not supporting layouts through block supports as the Group block does. The layout block support might provide further clues.
A separate PR to address this sounds good to me.
When the Site Logo is not aligned, the focus “border” when the block is selected takes up the full width of the container, rather than just highlighting the logo itself. This is consistent with the Image block and therefore I don’t think this needs to be remedied in this PR.
Agreed. It would be good though to put this into an issue so it doesn't fall through the cracks.
The focus border/outline in this PR does appear consistent with the image block but less than ideal.
When the Site Logo is reset, the Placeholder can appear different than expected.
This could possibly be improved by adding setAttributes( { width: undefined } );
within the onRemoveLogo
callback. Without the width
value set it picks up the is-default-size
CSS class again.
If resetting the logo image, it makes sense to me to also reset any custom width for it. I don't have a lot of context in terms of the history here so I don't feel strongly about it.
@@ -1,4 +1,5 @@ | |||
.wp-block[data-align="center"] > .wp-block-site-logo { | |||
display: table; | |||
margin-left: auto; | |||
margin-right: auto; | |||
text-align: center; |
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.
I'm not sure this text-align: center;
is required in the editor. With or without the resizable box inside the site logo block wrapper it stays aligned to the center for me.
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.
Good point, I will test further and remove later today.
Thanks for testing and the feedback @aaronrobertshaw. I will look into this today and also add a separate issue concerning the border. I will also look into another PR for the missing |
Hi, is this PR ready to be reviewed again? I see some comments that are not addressed? |
@carolinan admittedly, this fell off my radar. I will review again today. I believe this PR is good, but I need to create separate issues/PRs for things that surfaced in testing this PR. |
I have removed the unnecessary text alignment CSS that @aaronrobertshaw highlighted and thoroughly retested this. All works as expected and this is ready to be merged/backported unless anyone has objections. I am working on separate issues for the border issue (not directly related to this PR) and right/left alignment is covered here #36624. |
I have gone ahead and also added this fix to the PR as well. Since the user is "reseting" the image, I think it makes sense to also reset the width to default. This PR is ready to merge unless there are any further objections. The alignRight/alignLeft issue is noted in #36624 and will be addressed post-5.9. |
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 @ndiego!
I tested a bit and it seems to work well. I would also defer to @jasmussen about the style changes as he recently worked on them and could have feedback for the focus issue when no align is set.
@@ -10,20 +10,6 @@ | |||
pointer-events: none; | |||
} | |||
|
|||
&:not(.is-default-size) { |
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.
Why did you remove these styles? Is it because this change const currentWidth = width || defaultWidth;
? You have kept the addition of this class in code though - should we remove the code as well?
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.
Yeah that's correct. However .is-default-size
is used on the placeholder for when there is no set Site Logo, or the user resets the logo. This class is added to blockProps
which wraps both the placeholder and the actual Site logo when set, so I just opted to leave it. On the frontend, this class is added if no custom size is set.
Thanks for testing @ntsekouras and @jasmussen. I have added comments above and made changes based on your suggestions. |
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 again Nick! Since the style changes made sense to Joen as well, I think this is good to go!
Wait for green CI and 🚢
@ntsekouras it looks like one of the tests is failing, but I can't figure out why. The error message does not seem to refer to the Site Logo block. Any insight on this? |
The. failures seem completely unrelated. I restarted the tests, so let's see.. 😄 |
@ntsekouras looks like all the tests have passed! I have not merged a Gutenberg PR before. I assume "Squash and merge" or should it be "Rebase and merge"? Appreciate your help 😉 |
Nice work on this PR @ndiego! Merge this using the "Squash and merge" option, tidy up the commit message as appropriate, and enjoy. I'll let you do the honors 🙂 |
Haha thanks! |
* Remove duplicate alignment class. * Copy editor aligncenter styling from editor to frontend. * Ensure default width is set properly and remove conflicting CSS. * Revert some CSS changes after testing. * Remove unnecessary text alignment CSS. * Set the Site Logo width to default when reset. * Remove unnecessary align attribute.
Description
Fixes #36606. I have identified a handful of alignment issues with the Site Logo block that make it quite unwieldy in FSE themes.
Alignment Issues
Related Issues
In exploring these issues, there were a couple other discoveries as well.
A. The alignment class is output twice in the blockProps markup.
B. The default Site Logo size is set both in the Editor CSS as well as in the component itself. The CSS in the editor is not needed.
This PR addresses issues 1 and 3 of the alignment issues and A and B of the related issues. Issue 2 will need to be addressed in a separate PR and impacts more than just the Site Logo block.
PR Notes
There are a couple things to note with the changes proposes. When the Site Logo is not aligned, the focus “border” when the block is selected takes up the full width of the container, rather than just highlighting the logo itself. This is consistent with the Image block and therefore I don’t think this needs to be remedied in this PR.
When the Site Logo is reset, the Placeholder can appear different than expected. If the logo had not been manually resized, the placeholder looks correct. If it had been resized prior to being reset, the block no longer has the
.is-default-size
class resulting in some unique behavior depending on how the Site Logo was aligned. This was true prior to this PR, but is exacerbated a bit when the Site logo has no set alignment after this PR. I would recommend the placeholder be iterated on in another PR, but can work on it here as well if requested.How has this been tested?
This was tested using Twenty Twenty-Two and emptytheme in Gutenberg 11.9.1 and WordPress 5.8.2.
Screenshots
Types of changes
Bug fix
Checklist:
*.native.js
files for terms that need renaming or removal).