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 Apr 25, 2024
1 parent 41c80e8 commit 7683e4c
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions packages/edit-post/src/components/layout/index.js
Expand Up @@ -28,7 +28,7 @@ import { ScrollLock } from '@wordpress/components';
import { useViewportMatch } from '@wordpress/compose';
import { PluginArea } from '@wordpress/plugins';
import { __, _x, sprintf } from '@wordpress/i18n';
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,13 +135,11 @@ function Layout( { initialPost } ) {
useCommonCommands();

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

const { closeGeneralSidebar } = useDispatch( editPostStore );
const { createErrorNotice } = useDispatch( noticesStore );
const { setIsInserterOpened } = useDispatch( editorStore );
const {
mode,
isFullscreenActive,
Expand Down Expand Up @@ -204,18 +202,6 @@ function Layout( { initialPost } ) {

const styles = useEditorStyles();

// 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 7683e4c

Please sign in to comment.