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

Centered images broken inside innerBlocks for WordPress 6.2 #49542

Open
smerriman opened this issue Apr 3, 2023 · 5 comments
Open

Centered images broken inside innerBlocks for WordPress 6.2 #49542

smerriman opened this issue Apr 3, 2023 · 5 comments
Labels
[Block] Image Affects the Image Block [Block] Media & Text Affects the Media & Text Block [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P [Type] Bug An existing feature does not function as intended

Comments

@smerriman
Copy link

smerriman commented Apr 3, 2023

Description

For any custom block that uses innerBlocks, when you center an image inside the innerBlocks, it does not appear centered, either in the editor or on the front-end.

Step-by-step reproduction instructions

Install a default theme, e.g. Twenty Twenty-Two.

Add any custom block that uses innerBlocks - for example, the first one here: https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/nested-blocks-inner-blocks/

Insert the block, then insert an image inside, and attempt to center it. It won't be centered in the editor, nor if you view the result on the front-end.

From an initial inspection, it looks like the CSS for centered images has changed to only center images within is-layout-flow, or something along those lines, which doesn't exist for other blocks.

Screenshots, screen recording, code snippet

No response

Environment info

WordPress 6.2, no Gutenberg plugin

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

@smerriman
Copy link
Author

smerriman commented Apr 3, 2023

Note that the same applies to some core blocks too; e.g. if you add a Media + Text block, and insert a (secondary) image within the Text column.

@mrfoxtalbot
Copy link

Could this be related to #49549 ?

@mrfoxtalbot mrfoxtalbot added the Needs Testing Needs further testing to be confirmed. label Apr 3, 2023
@bph bph added the [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P label Apr 4, 2023
@ndiego
Copy link
Member

ndiego commented Apr 4, 2023

I am able to replicate this issue using the Media & Text block. See the linked gif below: https://d.pr/i/ev9FJL

However, as a temporary solution, if you wrap the image in a Group block, the alignments do work as expected.

@ndiego ndiego added [Block] Image Affects the Image Block and removed Needs Testing Needs further testing to be confirmed. labels Apr 4, 2023
@t-hamano
Copy link
Contributor

t-hamano commented Apr 5, 2023

I too can reproduce this problem.

Perhaps this problem has existed for some time and is related to a change in the markup of the image block.

According to this article, the HTML differs depending on the presence or absence of theme.json. Therefore, the classic theme with traditional markup will not reproduce this problem.

I think we need to define a centered style to accommodate the new markup.

Twenty Twenty One (Classic Theme)

HTML structure: div.wp-block-image > figure.aligncenter > img

classic

Twenty Twenty Three (Block Theme)

HTML structure: figure.wp-block-image.aligncenter > img

block

@mrfoxtalbot
Copy link

mrfoxtalbot commented Aug 28, 2023

This is still relevant and is also being discussed in Trac and I found an example of someone experiencing this issue in the support forums.

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 [Block] Media & Text Affects the Media & Text Block [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

6 participants