From 170b71e3db2dfcda1a859014c734a43030e2b0a9 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Tue, 7 Apr 2020 14:49:16 +0100 Subject: [PATCH] Only scroll page for multi-selectiions --- .../multi-select-scroll-into-view/index.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/block-editor/src/components/multi-select-scroll-into-view/index.js b/packages/block-editor/src/components/multi-select-scroll-into-view/index.js index 3443ee44d2956..025a2628bff18 100644 --- a/packages/block-editor/src/components/multi-select-scroll-into-view/index.js +++ b/packages/block-editor/src/components/multi-select-scroll-into-view/index.js @@ -21,19 +21,25 @@ import { getBlockDOMNode } from '../../utils/dom'; */ export default function MultiSelectScrollIntoView() { const selector = ( select ) => { - const { getBlockSelectionEnd, isMultiSelecting } = select( - 'core/block-editor' - ); + const { + getBlockSelectionEnd, + hasMultiSelection, + isMultiSelecting, + } = select( 'core/block-editor' ); return { selectionEnd: getBlockSelectionEnd(), + isMultiSelection: hasMultiSelection(), isMultiSelecting: isMultiSelecting(), }; }; - const { selectionEnd, isMultiSelecting } = useSelect( selector, [] ); + const { isMultiSelection, selectionEnd, isMultiSelecting } = useSelect( + selector, + [] + ); useEffect( () => { - if ( ! selectionEnd || isMultiSelecting ) { + if ( ! selectionEnd || isMultiSelecting || ! isMultiSelection ) { return; } @@ -54,7 +60,7 @@ export default function MultiSelectScrollIntoView() { scrollIntoView( extentNode, scrollContainer, { onlyScrollIfNeeded: true, } ); - }, [ selectionEnd, isMultiSelecting ] ); + }, [ isMultiSelection, selectionEnd, isMultiSelecting ] ); return null; }