Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inspector opening on click outside widget area #32450

Merged
merged 1 commit into from
Jun 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions packages/edit-widgets/src/components/sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) {
Expand All @@ -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,
};
}, [] );
Expand Down