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

Vertical alignment of flex containers incorrect on front end #41324

Closed
justintadlock opened this issue May 25, 2022 · 11 comments
Closed

Vertical alignment of flex containers incorrect on front end #41324

justintadlock opened this issue May 25, 2022 · 11 comments
Labels
[Block] Buttons Affects the Buttons Block [Block] Group Affects the Group Block (and row, stack and grid variants) [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Type] Bug An existing feature does not function as intended

Comments

@justintadlock
Copy link
Contributor

justintadlock commented May 25, 2022

Description

When adding a Row block or a Buttons block, the vertical alignment of the nested blocks is correctly applied in the editor. However, on the front end, the blocks are always aligned in the center. Issue reported here: https://wordpress.org/support/topic/6-0-rc4-layout-for-row-block-is-always-align-items-center/

In the editor, the container is given align-items: flex-start;. On the front end, the container is give align-items: center;.

Issue #35849 seems to be a related ticket, but it is suggesting that we add vertical alignment controls. However, these controls are already present.

Step-by-step reproduction instructions

  1. Add a Row block
  2. Add two or more nested blocks
  3. Select "align top" from the toolbar
  4. Save and check the front-end view

Screenshots, screen recording, code snippet

Editor view:

row-align-top-editor

Front-end view:

row-align-top-front

Environment info

No response

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

@justintadlock justintadlock added [Type] Bug An existing feature does not function as intended [Block] Buttons Affects the Buttons Block [Block] Group Affects the Group Block (and row, stack and grid variants) [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi labels May 25, 2022
@justintadlock
Copy link
Contributor Author

Actually, this seems to work in Gutenberg 13.2.2. It doesn't in WordPress 6.0. Closing for now.

@britweb-tim
Copy link

britweb-tim commented May 25, 2022

This seems to be an issue when upgrading sites using gutenberg to WP 6.0. The "core/columns" block now falls back to verticalAlign center if it's not explicitly set, but the editor shows them as "top" aligned. Cannot override this fallback on a theme.

@justintadlock
Copy link
Contributor Author

justintadlock commented May 25, 2022

I believe I have tracked down the vertical alignment issue with flex layouts. It looks like the PHP change from /lib/block-suports/layout.php was not ported over to WordPress into /wp-includes/block-supports/layout.php.

Here's the original PR: #40013

Current code in Gutenberg trunk: https://github.com/WordPress/gutenberg/blob/trunk/lib/block-supports/layout.php#L117-L131

Current code in WordPress 6.0 branch: https://github.com/WordPress/WordPress/blob/6.0-branch/wp-includes/block-supports/layout.php#L117-L126

@adamziel - Pinging you here as requested to find the best way forward.

@ndiego
Copy link
Member

ndiego commented May 26, 2022

I just added this to the 6.0.1 Project Board.

@Stephan66
Copy link

This issue has NOT been resolved with WordPress 6.0.1, the frontend still behaves as Justin described.

@devboldium
Copy link

This issue has NOT been resolved with WordPress 6.0.1, the frontend still behaves as Justin described.
Can confirm this is still happening in 6.0.1.

@adamziel
Copy link
Contributor

adamziel commented Aug 3, 2022

cc @ockham who'll lead the next Core Editor merge.

@ockham
Copy link
Contributor

ockham commented Aug 10, 2022

cc @ockham who'll lead the next Core Editor merge.

Thanks! Added to the (newly created) WP 6.1 Editor Tasks board 👍

@shanemac10
Copy link

shanemac10 commented Aug 30, 2022

Just updated to Version 6.0.2 and this is still happening. Please address this.

Can we just have alignment based classnames dynamically added to the block so us devs can add style overrides? This dynamic wp-container-<number> classname and dedicated style tag generation thing that's going on is not helpful for building on top of Wordpress.

@llslim
Copy link

llslim commented Sep 5, 2022

Can confirm this is not fix in 6.0.2 temporary workaround until fix ..

// remove layout support styles until vertical align gets updated in wp 6.1
// SPECIFIC_BLOCK_NAME == core/group

function ussaac_remove_group_layout_support_flag($block_content,$block) {
if (('SPECIFIC_BLOCK_NAME' === $block['blockName']) && is_page('YOUR PAGE')) {
remove_filter( 'render_block', 'wp_render_layout_support_flag', 10, 2 );
remove_filter( 'render_block', 'gutenberg_render_layout_support_flag', 10, 2 );
}
return $block_content;
}

add_filter('render_block','ussaac_remove_group_layout_support_flag', 9, 2);

@tellthemachines
Copy link
Contributor

The updated layout code has now been backported to Core and testing shows it working correctly in trunk:

Screen Shot 2022-09-27 at 5 01 20 pm

I'm going to go ahead and close this issue for now.

Repository owner moved this from Triage to Done in WordPress 6.0.x Editor Tasks Sep 27, 2022
Repository owner moved this from Triage to Done in WordPress 6.1 Editor Tasks Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Buttons Affects the Buttons Block [Block] Group Affects the Group Block (and row, stack and grid variants) [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Type] Bug An existing feature does not function as intended
Projects
No open projects
Development

No branches or pull requests

10 participants