-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Grid: In RTL languages, the resize handles point in the opposite direction #64995
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review!
This PR works fine horizontally, but seems to cause unintended issues vertically. The resizable box stretches from the center, not the top or bottom:
28794d3c28e6aeea417de5b4f2605c3d.mp4
I think the reason is that none of the conditions here are met when the direction is top
or bottom
. I think it will work if we make the following changes:
diff --git a/packages/block-editor/src/components/grid/grid-item-resizer.js b/packages/block-editor/src/components/grid/grid-item-resizer.js
index 0b63580149..7bd5fae530 100644
--- a/packages/block-editor/src/components/grid/grid-item-resizer.js
+++ b/packages/block-editor/src/components/grid/grid-item-resizer.js
@@ -137,6 +137,8 @@ function GridItemResizerInner( {
setResizeDirection( 'right' );
} else if ( 'right' === direction ) {
setResizeDirection( 'left' );
+ } else {
+ setResizeDirection( direction );
}
} else {
/*
Hii @t-hamano , |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Just to be sure, I would appreciate additional feedback from @noisysocks and @tellthemachines.
I haven't tested the change, but conceptually this PR looks like it's in the right direction to me! The
|
@andrewserong Thanks for the feedback!
I have considered this approach as well. In the trunk branch, we can make the following changes to solve the problem as well: diff --git a/packages/block-editor/src/components/grid/grid-item-resizer.js b/packages/block-editor/src/components/grid/grid-item-resizer.js
index da3eb824fe..ffa93d8c01 100644
--- a/packages/block-editor/src/components/grid/grid-item-resizer.js
+++ b/packages/block-editor/src/components/grid/grid-item-resizer.js
@@ -3,6 +3,7 @@
*/
import { ResizableBox } from '@wordpress/components';
import { useState, useEffect } from '@wordpress/element';
+import { isRTL } from '@wordpress/i18n';
/**
* Internal dependencies
@@ -73,8 +74,8 @@ function GridItemResizerInner( {
}, [ blockElement, rootBlockElement ] );
const justification = {
- right: 'flex-start',
- left: 'flex-end',
+ right: isRTL() ? 'flex-end' : 'flex-start',
+ left: isRTL() ? 'flex-start' : 'flex-end',
};
const alignment = { However, I suspect the root cause is that the drag handle of the Therefore, I feel that the direction detected by the |
Good point, that makes sense to me now. Since the |
Since the I considered a different approach, but found that the problem could be solved by making the following changes in trunk: diff --git a/packages/block-editor/src/components/grid/grid-item-resizer.js b/packages/block-editor/src/components/grid/grid-item-resizer.js
index da3eb824fe..1277ac2a23 100644
--- a/packages/block-editor/src/components/grid/grid-item-resizer.js
+++ b/packages/block-editor/src/components/grid/grid-item-resizer.js
@@ -73,8 +73,8 @@ function GridItemResizerInner( {
}, [ blockElement, rootBlockElement ] );
const justification = {
- right: 'flex-start',
- left: 'flex-end',
+ right: 'left',
+ left: 'right',
};
const alignment = { This means that the
This seems like a simpler approach than having to add logic to consider whether the language is RTL or not. What do you think? |
Oh, I really like that idea. This makes sense, too, because we're dealing with a component that's about moving something visually, which is conceptually different to RTL language support 👍 |
@andrewserong Thanks for the feedback! @rohitmathur-7 Making the changes suggested in this comment seems the best option for now, could you update this PR? |
Yes sure @t-hamano , |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank for the update 👍
What?
Why?
How?
Testing Instructions