Skip to content

Commit 357ff01

Browse files
committed
Block overrides: Prevent content alignment from flipping on flex layouts
For flex layouts, Gutenberg translates "left" and "right" into "flex-start" and "flex-end" respectively. Flipping these for RTL sites actually has the wrong effect, because in RTL "left" (flex-start) is visually on the right, which is correct already (despite being wrong descriptively). See WordPress/Learn#2483, Follow-up to 2a95d17
1 parent c251ec4 commit 357ff01

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

source/wp-content/themes/wporg-parent-2021/inc/gutenberg-tweaks.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ function flip_layout_alignment_rtl( $parsed_block ) {
140140
return $parsed_block;
141141
}
142142

143-
if ( isset( $parsed_block['attrs']['layout']['justifyContent'] ) ) {
143+
if (
144+
isset( $parsed_block['attrs']['layout']['justifyContent'] ) &&
145+
isset( $parsed_block['attrs']['layout']['type'] ) &&
146+
'flex' !== $parsed_block['attrs']['layout']['type']
147+
) {
144148
if ( 'left' === $parsed_block['attrs']['layout']['justifyContent'] ) {
145149
$parsed_block['attrs']['layout']['justifyContent'] = 'right';
146150
} else if ( 'right' === $parsed_block['attrs']['layout']['justifyContent'] ) {

0 commit comments

Comments
 (0)