From ff2183a0a3dc10afb0d42499d128682d2898e227 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Wed, 27 Oct 2021 12:56:48 +0300 Subject: [PATCH] [Block Editor]: Fix shift+click on a child block with its parent selected --- .../use-block-props/use-multi-selection.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/block-editor/src/components/block-list/use-block-props/use-multi-selection.js b/packages/block-editor/src/components/block-list/use-block-props/use-multi-selection.js index 75e9dca6c322f..05dc9a1491c90 100644 --- a/packages/block-editor/src/components/block-list/use-block-props/use-multi-selection.js +++ b/packages/block-editor/src/components/block-list/use-block-props/use-multi-selection.js @@ -176,7 +176,6 @@ export function useMultiSelection( clientId ) { blockSelectionStart !== clientId && ! startParents?.includes( clientId ) ) { - toggleRichText( node, false ); const startPath = [ ...startParents, blockSelectionStart, @@ -187,8 +186,15 @@ export function useMultiSelection( clientId ) { ]; const depth = Math.min( startPath.length, endPath.length ) - 1; - multiSelect( startPath[ depth ], endPath[ depth ] ); - event.preventDefault(); + const start = startPath[ depth ]; + const end = endPath[ depth ]; + // Handle the case of having selected a parent block and + // then sfift+click on a child. + if ( start !== end ) { + toggleRichText( node, false ); + multiSelect( start, end ); + event.preventDefault(); + } } } else if ( hasMultiSelection() ) { // Allow user to escape out of a multi-selection to a