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)).
- `AlignmentMatrixControl`: Fix the `width` prop so it works as intended ([#43482](https://github.com/WordPress/gutenberg/pull/43482)).
- `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)).
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
4 changes: 1 addition & 3 deletions packages/data/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@
{ "path": "../priority-queue" },
{ "path": "../redux-routine" }
],
"include": [
"src/**/*"
]
"include": [ "src/**/*" ]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the latest trunk was merged, unexpected code reformatting was performed.
But since this change was made by the linter, it appears to be OK.

}