From 881ba6ee7b769305e31a227f02a1da66695d681b Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Fri, 4 Jun 2021 15:52:30 +1000 Subject: [PATCH] Fix inspector opening on click outside widget area --- .../edit-widgets/src/components/sidebar/index.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/edit-widgets/src/components/sidebar/index.js b/packages/edit-widgets/src/components/sidebar/index.js index 9f643c2ad9852d..7101d2daca1532 100644 --- a/packages/edit-widgets/src/components/sidebar/index.js +++ b/packages/edit-widgets/src/components/sidebar/index.js @@ -78,17 +78,17 @@ export default function Sidebar() { const selectedBlock = getSelectedBlock(); - let activeArea = getActiveComplementaryArea( editWidgetsStore.name ); - if ( ! activeArea ) { + const activeArea = getActiveComplementaryArea( editWidgetsStore.name ); + + let currentSelection = activeArea; + if ( ! currentSelection ) { if ( selectedBlock ) { - activeArea = BLOCK_INSPECTOR_IDENTIFIER; + currentSelection = BLOCK_INSPECTOR_IDENTIFIER; } else { - activeArea = WIDGET_AREAS_IDENTIFIER; + currentSelection = WIDGET_AREAS_IDENTIFIER; } } - const isSidebarOpen = !! activeArea; - let widgetAreaBlock; if ( selectedBlock ) { if ( selectedBlock.name === 'core/widget-area' ) { @@ -104,11 +104,11 @@ export default function Sidebar() { } return { - currentArea: activeArea, + currentArea: currentSelection, hasSelectedNonAreaBlock: !! ( selectedBlock && selectedBlock.name !== 'core/widget-area' ), - isGeneralSidebarOpen: isSidebarOpen, + isGeneralSidebarOpen: !! activeArea, selectedWidgetAreaBlock: widgetAreaBlock, }; }, [] );