Skip to content
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

fixed the social icon block alignment issue #43056

Closed
wants to merge 1 commit into from
Closed

fixed the social icon block alignment issue #43056

wants to merge 1 commit into from

Conversation

Smit2808
Copy link
Contributor

@Smit2808 Smit2808 commented Aug 8, 2022

What?

Social icons block has center align issue in some themes like Twenty Twenty-Two and TT1 Blocks. And by discussing with core member @sabernhardt, we conclude that this issue is of block not of the theme.

PR will fix: #43048

How?

In themes like Twenty Twenty-Two and TT1 Blocks, the justify-content: flex-start; style is added to the container class so it was overriding the social icon block center CSS.

/* block-library/style.css */
.wp-block-social-links.aligncenter {
display: flex;
justify-content: center;
}

So to fix this issue, I created a strong hierarchy to override the justify-content: flex-start; style.

Testing Instructions

  1. Activate the Twenty Twenty-Two theme.
  2. Create a new post and insert a social icon block. Note: If you add the social icons block in the Site Editor, the option to align left/center/right is not always available.
  3. Select "Align center" in the dropdown. This does not center the icons in the editor.

Screenshots or screencast

@sabernhardt
Copy link
Contributor

Thanks for the PR!

  1. CSS rules need a space between the selector and the opening curly brace.
  2. The selector could be less specific. body .wp-block-social-links.aligncenter would be enough, though perhaps .wp-block.wp-block-social-links.aligncenter could be preferable.
  3. This stylesheet had a fix for centered social icons in WordPress 5.9, which needed updating when the wp-block class was moved to the same element as wp-block-social-links. I recommend adding the new selector there instead of at the bottom.
    // Center flex items. This has an equivalent in style.scss.
    .wp-block[data-align="center"] > .wp-block-social-links {
    justify-content: center;
    }
@Smit2808
Copy link
Contributor Author

Hi @sabernhardt,

Created new PR #43120. And Done all the changes you told me. Please review it.

Thank you.

@sabernhardt
Copy link
Contributor

Thanks! I do not have the setup to review that PR properly, but it looks good to me.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants