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 3 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
5 changes: 4 additions & 1 deletion packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const siteIconVariants = {
export default function EditSiteEditor( { isPostsList = false } ) {
const disableMotion = useReducedMotion();
const { params } = useLocation();
const { canvas = 'view' } = params;
const { canvas = 'view', path } = params;
const isLoading = useIsSiteEditorLoading();
useAdaptEditorToCanvas( canvas );
const {
Expand Down Expand Up @@ -242,6 +242,9 @@ export default function EditSiteEditor( { isPostsList = false } ) {
extraSidebarPanels={
! isEditingPage && <PluginTemplateSettingPanel.Slot />
}
__isDocumentSidebarActiveByDefault={
ellatrix marked this conversation as resolved.
Show resolved Hide resolved
path !== '/wp_global_styles'
}
>
{ isEditMode && (
<BackButton>
Expand Down
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
4 changes: 4 additions & 0 deletions packages/editor/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function Editor( {
// to account for site editor and post editor differences for now.
extraContent,
extraSidebarPanels,
__isDocumentSidebarActiveByDefault: isDocumentSidebarActiveByDefault,
...props
} ) {
const { post, template, hasLoadedPost } = useSelect(
Expand Down Expand Up @@ -76,6 +77,9 @@ function Editor( {
</EditorInterface>
{ children }
<Sidebar
isDocumentSidebarActiveByDefault={
isDocumentSidebarActiveByDefault
}
onActionPerformed={ onActionPerformed }
extraPanels={ extraSidebarPanels }
/>
Expand Down
14 changes: 12 additions & 2 deletions packages/editor/src/components/sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const SIDEBAR_ACTIVE_BY_DEFAULT = Platform.select( {
} );

const SidebarContent = ( {
isDocumentSidebarActiveByDefault,
tabName,
keyboardShortcut,
onActionPerformed,
Expand Down Expand Up @@ -107,7 +108,9 @@ const SidebarContent = ( {
}
toggleShortcut={ keyboardShortcut }
icon={ isRTL() ? drawerLeft : drawerRight }
isActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }
isActiveByDefault={
isDocumentSidebarActiveByDefault ?? SIDEBAR_ACTIVE_BY_DEFAULT
}
>
<Tabs.Context.Provider value={ tabsContextValue }>
<Tabs.TabPanel tabId={ sidebars.document } focusable={ false }>
Expand All @@ -128,7 +131,11 @@ const SidebarContent = ( {
);
};

const Sidebar = ( { extraPanels, onActionPerformed } ) => {
const Sidebar = ( {
extraPanels,
onActionPerformed,
isDocumentSidebarActiveByDefault,
} ) => {
useAutoSwitchEditorSidebars();
const { tabName, keyboardShortcut, showSummary } = useSelect(
( select ) => {
Expand Down Expand Up @@ -187,6 +194,9 @@ const Sidebar = ( { extraPanels, onActionPerformed } ) => {
showSummary={ showSummary }
onActionPerformed={ onActionPerformed }
extraPanels={ extraPanels }
isDocumentSidebarActiveByDefault={
isDocumentSidebarActiveByDefault
}
/>
</Tabs>
);
Expand Down
Loading