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

Grid: In RTL languages, the resize handles point in the opposite direction #64995

Merged
merged 5 commits into from
Sep 13, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions packages/block-editor/src/components/grid/grid-item-resizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import { ResizableBox } from '@wordpress/components';
import { useState, useEffect } from '@wordpress/element';
import { isRTL } from '@wordpress/i18n';

/**
* Internal dependencies
Expand Down Expand Up @@ -56,6 +57,8 @@ function GridItemResizerInner( {
right: false,
} );

const rtl = isRTL();

useEffect( () => {
const observer = new window.ResizeObserver( () => {
const blockClientRect = blockElement.getBoundingClientRect();
Expand Down Expand Up @@ -129,12 +132,20 @@ function GridItemResizerInner( {
target.setPointerCapture( pointerId );
} }
onResizeStart={ ( event, direction ) => {
/*
* The container justification and alignment need to be set
* according to the direction the resizer is being dragged in,
* so that it resizes in the right direction.
*/
setResizeDirection( direction );
if ( rtl ) {
if ( 'left' === direction ) {
setResizeDirection( 'right' );
} else if ( 'right' === direction ) {
setResizeDirection( 'left' );
}
} else {
/*
* The container justification and alignment need to be set
* according to the direction the resizer is being dragged in,
* so that it resizes in the right direction.
*/
setResizeDirection( direction );
}
} }
onResizeStop={ ( event, direction, boxElement ) => {
const columnGap = parseFloat(
Expand Down
Loading