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

Social Links Block: Prevent Theme Styles Distorting Size #56301

Merged
merged 3 commits into from
Dec 4, 2023

Conversation

Aurorum
Copy link
Contributor

@Aurorum Aurorum commented Nov 19, 2023

Fixes #38043
Fixes #53077
Fixes Automattic/themes#5345
Fixes Automattic/themes#6532
Fixes Automattic/themes#6817
Partly fixes Automattic/themes#7062
Fixes Automattic/wp-calypso#79942
etc.

What?

Ensures that theme styles do not distort the Social Links block.

Why?

The Social Links block is a list. As a result, it inherits a lot of styling from different themes, especially in the Widget Area where themes tend to style lists more specifically. The block already does a lot to override this, but it should also deal with margin and padding so that it's not distorted on themes.

Automattic/themes#5345 and Automattic/themes#6532 have a long list of themes affected by this, so I'd suggest that a Core fix is more appropriate here.

How?

Overrides any margin and padding set by themes.

Testing Instructions

  1. Insert a Social Icons block on a theme like Twenty Seventeen in the widgets area
  2. Apply these CSS changes
  3. Confirm the difference

Screenshots or screencast

Before:
Screenshot 2023-11-19 at 15 04 54

After:
Screenshot 2023-11-19 at 15 04 44

@Aurorum Aurorum requested a review from ajitbohra as a code owner November 19, 2023 15:08
@Aurorum
Copy link
Contributor Author

Aurorum commented Nov 25, 2023

To merge this PR, it requires exactly 1 label indicating the type of PR.

Would be appreciated if somebody could add a label to this one! It'd be nice to see this looked at since there's been some more reports of this issue.

cc @jorgefilipecosta, @Mamaduka as most recent contributors to this block - sorry for the ping!

@apeatling apeatling added Needs Design Feedback Needs general design feedback. [Block] Social Affects the Social Block - used to display Social Media accounts [Type] Bug An existing feature does not function as intended labels Nov 30, 2023
Copy link
Contributor

@apeatling apeatling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed this fixes the issues listed. It would be good to get some feedback from @WordPress/gutenberg-design for any concerns about conflicts when setting margin/padding like this.

}
}

&:after {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a feeling this is the main part of the fix, but I'm also not sure. Can you speak a bit more about what this does? In the editor we do use some pseudo elements to display focus styles, just want to make sure we don't regress that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @jasmussen - no, the padding and margin is the main part of the fix which covers most themes. However, at least two themes which I tested also set an :after in the widget area (eg. see Apostrophe 2 in Automattic/themes#7062).

I feel that more than enough themes are affected to justify the padding and margin styles in Core, but I don’t mind particularly either way on this bit. However, since we already have a selector, I suspect that it’s probably easier for users and developers than hoping that themes update their styling for this block.

I hope that makes sense, and thanks for the review! :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is definitely valid, my question is mostly around this pseudo element. Do you know where this code is coming from?

Screenshot 2023-12-01 at 10 51 08

If it's reproducible in core on more than just one theme, for example with social icons in widgets on every theme that has widget areas, then the fix is definitely appropriate for core.

But if the CSS that appends a | is coming from a theme or a plugin, then it should not be fixed here, it should be fixed at the source. Makes sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense! A few themes are guilty of similar styling, but yes, it's from the theme: https://github.com/Automattic/themes/blob/012258cc65cfdfc99bc32117ef951f2c9dbb7189/apostrophe-2/style.css#L1411-L1415

I don't have a strong view either way as to whether there's enough themes affected to justify a Core fix, so I've removed that style from this PR - I'll fix it in the individual themes instead. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for removing. It's definitely important to not fix at the source, because like I said in some cases we use the pseudo selectors for other things, so this'll have to be a local fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes total sense! Please let me know if there are any issues with the remaining changes. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, hopefully @apeatling can give it a green check!

@jasmussen
Copy link
Contributor

I can't deeply test this morning, but at a glance this looks good. Left one question as a comment.

Copy link
Contributor

@apeatling apeatling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restested this in Twenty Seventeen, Astra, OceanWP, and Twenty Twenty Four. All worked well. I think this LGTM!

@apeatling apeatling merged commit c516601 into WordPress:trunk Dec 4, 2023
50 checks passed
@github-actions github-actions bot added this to the Gutenberg 17.3 milestone Dec 4, 2023
@Aurorum
Copy link
Contributor Author

Aurorum commented Dec 4, 2023

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Social Affects the Social Block - used to display Social Media accounts Needs Design Feedback Needs general design feedback. [Type] Bug An existing feature does not function as intended
Projects
None yet
3 participants