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

Site Editor > Styles: open styles inspector when clicking preview canvas #66996

Merged
merged 8 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -29,7 +29,7 @@ const { useLocation } = unlock( routerPrivateApis );

export default function GlobalStylesSidebar() {
const { params } = useLocation();
const { canvas = 'view' } = params;
const { canvas = 'view', path } = params;
const {
shouldClearCanvasContainerView,
isStyleBookOpened,
Expand Down Expand Up @@ -135,6 +135,7 @@ export default function GlobalStylesSidebar() {
title={ __( 'Styles' ) }
icon={ styles }
closeLabel={ __( 'Close Styles' ) }
isActiveByDefault={ path === '/wp_global_styles' }
panelClassName="edit-site-global-styles-sidebar__panel"
header={
<Flex
Expand Down
9 changes: 6 additions & 3 deletions packages/interface/src/components/complementary-area/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ function ComplementaryArea( {
isActive,
isSmall
);
const { getActiveComplementaryArea } = useSelect( interfaceStore );
const {
enableComplementaryArea,
disableComplementaryArea,
Expand All @@ -241,22 +242,24 @@ function ComplementaryArea( {
} = useDispatch( interfaceStore );

useEffect( () => {
// Make sure we have the latest active area.
const freshActiveArea = getActiveComplementaryArea( scope );
// Set initial visibility: For large screens, enable if it's active by
// default. For small screens, always initially disable.
if ( isActiveByDefault && activeArea === undefined && ! isSmall ) {
if ( isActiveByDefault && freshActiveArea === undefined && ! isSmall ) {
enableComplementaryArea( scope, identifier );
} else if ( activeArea === undefined && isSmall ) {
} else if ( freshActiveArea === undefined && isSmall ) {
disableComplementaryArea( scope, identifier );
ellatrix marked this conversation as resolved.
Show resolved Hide resolved
}
setIsReady( true );
}, [
activeArea,
isActiveByDefault,
scope,
identifier,
isSmall,
enableComplementaryArea,
disableComplementaryArea,
getActiveComplementaryArea,
] );

if ( ! isReady ) {
Expand Down
Loading