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

AlignmentMatrixControl: keep the physical direction in RTL languages #43126

Merged
merged 9 commits into from
Aug 26, 2022
18 changes: 15 additions & 3 deletions packages/block-library/src/cover/edit/block-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
__experimentalBlockAlignmentMatrixControl as BlockAlignmentMatrixControl,
__experimentalBlockFullHeightAligmentControl as FullHeightAlignmentControl,
} from '@wordpress/block-editor';
import { __ } from '@wordpress/i18n';
import { __, isRTL } from '@wordpress/i18n';

/**
* Internal dependencies
Expand Down Expand Up @@ -58,15 +58,27 @@ export default function CoverBlockControls( {
} );
};

// Flip value horizontally to match the physical direction indicated by
// AlignmentMatrixControl with the logical direction indicated by cover
// block in RTL languages.
const flipHorizontalPosition = ( ltrContentPosition ) => {
return isRTL()
? ltrContentPosition.replace( /left|right/, ( match ) =>
match === 'left' ? 'right' : 'left'
)
: ltrContentPosition;
};

return (
<>
<BlockControls group="block">
<BlockAlignmentMatrixControl
label={ __( 'Change content position' ) }
value={ contentPosition }
value={ flipHorizontalPosition( contentPosition ) }
onChange={ ( nextPosition ) =>
setAttributes( {
contentPosition: nextPosition,
contentPosition:
flipHorizontalPosition( nextPosition ),
} )
}
isDisabled={ ! hasInnerBlocks }
Expand Down
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

### Bug Fix

- `AlignmentMatrixControl`: keep the physical direction in RTL languages ([#43126](https://github.com/WordPress/gutenberg/pull/43126)).
- `SelectControl`, `CustomSelectControl`: Truncate long option strings ([#43301](https://github.com/WordPress/gutenberg/pull/43301)).
- `Popover`: fix and improve opening animation ([#43186](https://github.com/WordPress/gutenberg/pull/43186)).
- `Popover`: fix incorrect deps in hooks resulting in incorrect positioning after calling `update` ([#43267](https://github.com/WordPress/gutenberg/pull/43267/)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const rootBase = () => {
return css`
border-radius: 2px;
box-sizing: border-box;
direction: ltr;
display: grid;
grid-template-columns: repeat( 3, 1fr );
outline: none;
Expand Down