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

Image left/right alignment escapes it's container in the editor #37504

Closed
creativecoder opened this issue Dec 18, 2021 · 3 comments
Closed

Image left/right alignment escapes it's container in the editor #37504

creativecoder opened this issue Dec 18, 2021 · 3 comments
Labels
[Block] Image Affects the Image Block [Type] Bug An existing feature does not function as intended

Comments

@creativecoder
Copy link
Contributor

Description

When an image is left or right aligned, how it looks on the editor does not match the actual site.

Step-by-step reproduction instructions

  1. Create a new post or page
  2. Insert an image block, make it relatively small, and set it to left aligned
  3. Insert a spacer block after it
  4. Insert some text after that

I expect that the image is left aligned with the text, but it's not

Screenshots, screen recording, code snippet

Editor

image

Front end

image


Note that the float for alignment is applied to the block container in the editor

image

But the figure element inside the container on the front-end

image

Environment info

  • WP 5.9, Gutenberg 12.1.0-rc.1
  • Firefox, macOS

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@creativecoder creativecoder added the [Type] Bug An existing feature does not function as intended label Dec 18, 2021
@creativecoder creativecoder added the [Block] Image Affects the Image Block label Dec 18, 2021
@maxwrlr
Copy link

maxwrlr commented Mar 1, 2022

I have the same problem. I temporarily solve it with an editor-style:

.editor-styles-wrapper .block-editor-block-list__layout.is-root-container > .wp-block[data-align="left"] {
	margin-left: calc((100% -  <value-of-settings.layout.contentSize-of-theme.json>   ) / 2) !important;
}

@creativecoder
Copy link
Contributor Author

It appears this is now at least consistent, if not expected. Left or right aligned images now escape the container on the front end, as well.

@itsdavidmorgan
Copy link

A modified version of @maxwrlr solution worked for me:

.is-layout-constrained > .wp-block.alignleft {
	margin-left: calc((100% - var(--wp--style--global--content-size)) / 2) !important;
}
.is-layout-constrained > .wp-block.alignright {
	margin-right: calc((100% - var(--wp--style--global--content-size)) / 2) !important;
}

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 [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

3 participants