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 disable DFM when opening styles command #52165

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
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
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