From f9f8c4e9b80a7c799564cb618d7624430504b4d5 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Mon, 10 Apr 2023 11:33:32 +0100 Subject: [PATCH] Fix inbetween-inserter position in RTL languages --- .../block-list/use-in-between-inserter.js | 5 ++++- .../src/components/block-popover/inbetween.js | 15 ++------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/packages/block-editor/src/components/block-list/use-in-between-inserter.js b/packages/block-editor/src/components/block-list/use-in-between-inserter.js index 506fc718243b0e..6e9365ad102242 100644 --- a/packages/block-editor/src/components/block-list/use-in-between-inserter.js +++ b/packages/block-editor/src/components/block-list/use-in-between-inserter.js @@ -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 @@ -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 ) ) ); } ); diff --git a/packages/block-editor/src/components/block-popover/inbetween.js b/packages/block-editor/src/components/block-popover/inbetween.js index f9dd7adde42fb9..6a215363c39013 100644 --- a/packages/block-editor/src/components/block-popover/inbetween.js +++ b/packages/block-editor/src/components/block-popover/inbetween.js @@ -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 @@ -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