Skip to content

Commit

Permalink
Post Editor: Do not close the sidebar when opening the inserter
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Mar 21, 2024
1 parent 74a06c7 commit 3ad36b1
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions packages/edit-post/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
InterfaceSkeleton,
store as interfaceStore,
} from '@wordpress/interface';
import { useState, useEffect, useCallback, useMemo } from '@wordpress/element';
import { useState, useCallback, useMemo } from '@wordpress/element';
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
import { store as noticesStore } from '@wordpress/notices';
import { store as preferencesStore } from '@wordpress/preferences';
Expand Down Expand Up @@ -135,14 +135,11 @@ function Layout( { initialPost } ) {
useCommonCommands();

const isMobileViewport = useViewportMatch( 'medium', '<' );
const isHugeViewport = useViewportMatch( 'huge', '>=' );
const isWideViewport = useViewportMatch( 'large' );
const isLargeViewport = useViewportMatch( 'medium' );

const { openGeneralSidebar, closeGeneralSidebar } =
useDispatch( editPostStore );
const { openGeneralSidebar } = useDispatch( editPostStore );
const { createErrorNotice } = useDispatch( noticesStore );
const { setIsInserterOpened } = useDispatch( editorStore );
const {
mode,
isFullscreenActive,
Expand Down Expand Up @@ -211,18 +208,6 @@ function Layout( { initialPost } ) {
hasBlockSelected ? 'edit-post/block' : 'edit-post/document'
);

// Inserter and Sidebars are mutually exclusive
useEffect( () => {
if ( sidebarIsOpened && ! isHugeViewport ) {
setIsInserterOpened( false );
}
}, [ isHugeViewport, setIsInserterOpened, sidebarIsOpened ] );
useEffect( () => {
if ( isInserterOpened && ! isHugeViewport ) {
closeGeneralSidebar();
}
}, [ closeGeneralSidebar, isInserterOpened, isHugeViewport ] );

// Local state for save panel.
// Note 'truthy' callback implies an open panel.
const [ entitiesSavedStatesCallback, setEntitiesSavedStatesCallback ] =
Expand Down

0 comments on commit 3ad36b1

Please sign in to comment.