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

.wp-block-image margin-bottom is incorrectly applied when aligned left/right #16241

Closed
2 tasks
benlk opened this issue Jun 21, 2019 · 8 comments
Closed
2 tasks
Labels
[Block] Image Affects the Image Block [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. Needs Design Feedback Needs general design feedback.

Comments

@benlk
Copy link
Contributor

benlk commented Jun 21, 2019

Describe the bug

Screen Shot 2019-06-21 at 12 07 28

The problem is that a .wp-block-image block with an alignright image retains the margin-bottom on the parent element, and as a result the following paragraph tag does not align with the top of the image/

To reproduce
Steps to reproduce the behavior:

  1. With WordPress 5.2.2.1 and no Gutenberg plugin
  2. Add an image block aligned right that is less than the full column width.
  3. Following the image block, add a paragraph text block.
  4. See error

Expected behavior
I expect the top of the image to be level with the top of the adjacent paragraph tag.

Screenshots
Screen Shot 2019-06-21 at 12 07 28
Screen Shot 2019-06-21 at 12 07 33
Screen Shot 2019-06-21 at 12 07 48

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: Chrome
  • Version: 75

Suggested fix

  • remove the margin-bottom on .wp-block-image in /wp-includes/css/dist/block-library/style.min.css?ver=5.2.2
  • add a margin-bottom to the <figure> element in the optional styles that themes can opt out of. Themes generally provide their own margin styles for .alignright.
@GlennMartin1
Copy link

Related? woocommerce/storefront#1165

@benlk
Copy link
Contributor Author

benlk commented Jun 21, 2019

@tiagonoronha didn't specify the source of the misaligning when the ticket was reported, so there's no way to be absolutely certain.

I'd agree with you, @GlennMartin1, because based on the diff that ticket does look like it's reporting this same issue. The fix that theme implemented is that I would implement in my themes, if there was not going to be a fix for this in Gutenberg.

@noisysocks
Copy link
Member

Definitely looks like something is awry.

Here's what I see when I follow the steps to reproduce using latest Gutenberg + Twenty Twenty:

Screen Shot 2020-03-19 at 16 41 23

And here's it using latest Gutenberg + Twenty Nineteen:

Screen Shot 2020-03-19 at 16 43 22

I'm unsure if this is an issue in the block editor that's being patched by Twenty Twenty, or if this is an issue in Twenty Nineteen.

Adding Needs Design Feedback in the hopes that someone familiar with the CSS here can chime in.

@noisysocks noisysocks added [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. Needs Design Feedback Needs general design feedback. and removed Needs Testing Needs further testing to be confirmed. labels Mar 19, 2020
@richtabor
Copy link
Member

We chatted about this issue in today's design meeting (Slack).

It's really difficult to match paragraph and image placements for right/left images. We could probably get it right for baseline/default Gutenberg styles - but not for every theme out there. It's dependent on font size, line height, paragraph margin/padding as well.

@benlk
Copy link
Contributor Author

benlk commented Jul 14, 2020

In the theme I screenshot, the paragraph had no margin-top; the theme uses margin-bottom to space between paragraphs. The .wp-block-image{ margin-bottom: 1em } margin-bottom comes from wp-includes/css/dist/block-library/style.min.css?ver=5.4.2.

Maybe Twenty Twenty uses margin-top on paragraphs, and that's why it matches, where Twenty Nineteen uses margin-bottom, and that's why it doesn't match.

My questions are:

  • Why does Gutenberg take responsibility for matching paragraph and image placements? Shouldn't this be the theme's job instead of the editor's job?
  • Can this style be removed from Core?

@paaljoachim
Copy link
Contributor

paaljoachim commented Oct 27, 2020

Is this issue still valid?

@GlennMartin1
Copy link

Is this issue still valid?

I don't know. My earlier comment was using Storefront, but it's been addressed there (see woocommerce/storefront#1165).

@paaljoachim
Copy link
Contributor

paaljoachim commented Feb 10, 2021

I tested with WordPress 5.7 beta 1.
Only the WordPress Beta tester plugin is activated.
Theme: Twenty Twenty One.

Aligning the image right.
Adding a paragraph.

Screen Shot 2021-02-10 at 15 40 01

It looks pretty good. I will close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Image Affects the Image Block [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. Needs Design Feedback Needs general design feedback.
Projects
None yet
Development

No branches or pull requests

6 participants