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

Reintroduce styles=open parameter to open the styles panel directly #49731

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
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: 15 additions & 1 deletion packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { useMemo } from '@wordpress/element';
import { useMemo, useEffect } from '@wordpress/element';
import { useSelect, useDispatch } from '@wordpress/data';
import { Notice } from '@wordpress/components';
import { EntityProvider } from '@wordpress/core-data';
Expand Down Expand Up @@ -102,6 +102,7 @@ export default function Editor() {
};
}, [] );
const { setEditedPostContext } = useDispatch( editSiteStore );
const { enableComplementaryArea } = useDispatch( interfaceStore );

const isViewMode = canvasMode === 'view';
const isEditMode = canvasMode === 'edit';
Expand Down Expand Up @@ -148,6 +149,19 @@ export default function Editor() {
);
}

useEffect(
function openGlobalStylesOnLoad() {
const searchParams = new URLSearchParams( window.location.search );
if ( searchParams.get( 'styles' ) === 'open' ) {
enableComplementaryArea(
'core/edit-site',
'edit-site/global-styles'
);
}
},
[ enableComplementaryArea ]
);

// Only announce the title once the editor is ready to prevent "Replace"
// action in <URlQueryController> from double-announcing.
useTitle( hasLoadedPost && title );
Expand Down