Skip to content

Commit

Permalink
Fix inbetween-inserter position in RTL languages (#49683)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored Apr 11, 2023
1 parent 79623c9 commit 32060b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { useRefEffect } from '@wordpress/compose';
import { useSelect, useDispatch } from '@wordpress/data';
import { useContext } from '@wordpress/element';
import { isRTL } from '@wordpress/i18n';

/**
* Internal dependencies
Expand Down Expand Up @@ -93,7 +94,9 @@ export function useInBetweenInserter() {
blockElRect.top > offsetTop ) ||
( blockEl.classList.contains( 'wp-block' ) &&
orientation === 'horizontal' &&
blockElRect.left > offsetLeft )
( isRTL()
? blockElRect.right < offsetLeft
: blockElRect.left > offsetLeft ) )
);
} );

Expand Down
15 changes: 2 additions & 13 deletions packages/block-editor/src/components/block-popover/inbetween.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,7 @@ function BlockPopoverInbetween( {
nextRect && previousRect
? nextRect.top - previousRect.bottom
: 0;

if ( isRTL() ) {
// vertical, rtl
left = previousRect
? previousRect.right
: nextRect.right;
} else {
// vertical, ltr
left = previousRect ? previousRect.left : nextRect.left;
}
left = previousRect ? previousRect.left : nextRect.left;
} else {
top = previousRect ? previousRect.top : nextRect.top;
height = previousRect
Expand All @@ -124,9 +115,7 @@ function BlockPopoverInbetween( {

if ( isRTL() ) {
// non vertical, rtl
left = previousRect
? previousRect.left
: nextRect.right;
left = nextRect ? nextRect.right : previousRect.left;
width =
previousRect && nextRect
? previousRect.left - nextRect.right
Expand Down

0 comments on commit 32060b8

Please sign in to comment.