Skip to content

Commit

Permalink
Fix disable DFM when opening styles command (#52165)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras authored and tellthemachines committed Jul 3, 2023
1 parent 0ea227a commit 9d456e4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,8 @@ export function SidebarNavigationItemGlobalStyles( props ) {
);
createNotice(
'info',
__( 'Distraction free mode turned off' ),
{
isDismissible: true,
type: 'snackbar',
}
__( 'Distraction free mode turned off.' ),
{ type: 'snackbar' }
);
}
// Switch to edit mode.
Expand Down
14 changes: 13 additions & 1 deletion packages/edit-site/src/hooks/commands/use-common-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
import { privateApis as routerPrivateApis } from '@wordpress/router';
import { store as preferencesStore } from '@wordpress/preferences';
import { store as coreStore } from '@wordpress/core-data';
import { store as noticesStore } from '@wordpress/notices';

/**
* Internal dependencies
Expand Down Expand Up @@ -104,14 +105,19 @@ export function useCommonCommands() {
useDispatch( editSiteStore )
);
const { set } = useDispatch( preferencesStore );
const { createInfoNotice } = useDispatch( noticesStore );
const history = useHistory();
const { homeUrl } = useSelect( ( select ) => {
const { homeUrl, isDistractionFree } = useSelect( ( select ) => {
const {
getUnstableBase, // Site index.
} = select( coreStore );

return {
homeUrl: getUnstableBase()?.home,
isDistractionFree: select( preferencesStore ).get(
editSiteStore.name,
'distractionFree'
),
};
}, [] );

Expand Down Expand Up @@ -139,6 +145,12 @@ export function useCommonCommands() {
path: '/wp_global_styles',
canvas: 'edit',
} );
if ( isDistractionFree ) {
set( editSiteStore.name, 'distractionFree', false );
createInfoNotice( __( 'Distraction free mode turned off.' ), {
type: 'snackbar',
} );
}
openGeneralSidebar( 'edit-site/global-styles' );
},
icon: styles,
Expand Down

0 comments on commit 9d456e4

Please sign in to comment.