Skip to content

Commit 0122f4d

Browse files
authored
Cover Block: Keep the inner contents in a physical direction even in RTL languages (#43663)
* Cover Block: Keep the inner contents in a physical direction even in RTL languages * Remove unnecessary change
1 parent 88f9456 commit 0122f4d

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

packages/block-library/src/cover/edit/block-controls.js

+3-15
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
__experimentalBlockAlignmentMatrixControl as BlockAlignmentMatrixControl,
1010
__experimentalBlockFullHeightAligmentControl as FullHeightAlignmentControl,
1111
} from '@wordpress/block-editor';
12-
import { __, isRTL } from '@wordpress/i18n';
12+
import { __ } from '@wordpress/i18n';
1313

1414
/**
1515
* Internal dependencies
@@ -58,27 +58,15 @@ export default function CoverBlockControls( {
5858
} );
5959
};
6060

61-
// Flip value horizontally to match the physical direction indicated by
62-
// AlignmentMatrixControl with the logical direction indicated by cover
63-
// block in RTL languages.
64-
const flipHorizontalPosition = ( ltrContentPosition ) => {
65-
return isRTL()
66-
? ltrContentPosition.replace( /left|right/, ( match ) =>
67-
match === 'left' ? 'right' : 'left'
68-
)
69-
: ltrContentPosition;
70-
};
71-
7261
return (
7362
<>
7463
<BlockControls group="block">
7564
<BlockAlignmentMatrixControl
7665
label={ __( 'Change content position' ) }
77-
value={ flipHorizontalPosition( contentPosition ) }
66+
value={ contentPosition }
7867
onChange={ ( nextPosition ) =>
7968
setAttributes( {
80-
contentPosition:
81-
flipHorizontalPosition( nextPosition ),
69+
contentPosition: nextPosition,
8270
} )
8371
}
8472
isDisabled={ ! hasInnerBlocks }

packages/block-library/src/cover/style.scss

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
padding: 1em;
1010
// This block has customizable padding, border-box makes that more predictable.
1111
box-sizing: border-box;
12+
// Keep the flex layout direction to the physical direction (LTR) in RTL languages.
13+
/*rtl:raw: direction: ltr; */
1214

1315
/**
1416
* Set a default background color for has-background-dim _unless_ it includes another
@@ -105,6 +107,8 @@
105107
width: 100%;
106108
z-index: z-index(".wp-block-cover__inner-container");
107109
color: $white;
110+
// Reset the fixed LTR direction at the root of the block in RTL languages.
111+
/*rtl:raw: direction: rtl; */
108112
}
109113

110114
&.is-light {

0 commit comments

Comments
 (0)