Skip to content

Commit

Permalink
Block overrides: Prevent content alignment from flipping on flex layouts
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ryelle committed Jul 9, 2024
1 parent c251ec4 commit 357ff01
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ function flip_layout_alignment_rtl( $parsed_block ) {
return $parsed_block;
}

if ( isset( $parsed_block['attrs']['layout']['justifyContent'] ) ) {
if (
isset( $parsed_block['attrs']['layout']['justifyContent'] ) &&
isset( $parsed_block['attrs']['layout']['type'] ) &&
'flex' !== $parsed_block['attrs']['layout']['type']
) {
if ( 'left' === $parsed_block['attrs']['layout']['justifyContent'] ) {
$parsed_block['attrs']['layout']['justifyContent'] = 'right';
} else if ( 'right' === $parsed_block['attrs']['layout']['justifyContent'] ) {
Expand Down

0 comments on commit 357ff01

Please sign in to comment.