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

Site Editor: Make resizable frame compatible with RTL languages #65545

Merged
merged 4 commits into from
Sep 24, 2024
Merged
Changes from 1 commit
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
17 changes: 12 additions & 5 deletions packages/edit-site/src/components/resizable-frame/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from '@wordpress/components';
import { useInstanceId, useReducedMotion } from '@wordpress/compose';
import { useDispatch, useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { __, isRTL } from '@wordpress/i18n';

/**
* Internal dependencies
Expand Down Expand Up @@ -171,7 +171,12 @@ function ResizableFrame( {
event.preventDefault();

const step = 20 * ( event.shiftKey ? 5 : 1 );
const delta = step * ( event.key === 'ArrowLeft' ? 1 : -1 );
const delta =
step *
( ( ! isRTL() && event.key === 'ArrowLeft' ) ||
( isRTL() && event.key === 'ArrowRight' )
? 1
: -1 );
t-hamano marked this conversation as resolved.
Show resolved Hide resolved
const newWidth = Math.min(
Math.max(
FRAME_MIN_WIDTH,
Expand Down Expand Up @@ -200,15 +205,17 @@ function ResizableFrame( {
const resizeHandleVariants = {
hidden: {
opacity: 0,
left: 0,
...( isRTL() ? { right: 0 } : { left: 0 } ),
},
visible: {
opacity: 1,
left: -14, // Account for the handle's width.
// Account for the handle's width.
...( isRTL() ? { right: -14 } : { left: -14 } ),
},
active: {
opacity: 1,
left: -14, // Account for the handle's width.
// Account for the handle's width.
...( isRTL() ? { right: -14 } : { left: -14 } ),
scaleY: 1.3,
},
};
Expand Down
Loading