Skip to content

Commit

Permalink
Fix rendering PluginTemplateSettingPanel when we're editing a template (
Browse files Browse the repository at this point in the history
WordPress#60215)

Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
  • Loading branch information
3 people authored and cbravobernal committed Apr 9, 2024
1 parent 3143a6b commit 7f6053f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,24 @@
/**
* WordPress dependencies
*/
import { store as editorStore } from '@wordpress/editor';
import { useSelect } from '@wordpress/data';
import { createSlotFill } from '@wordpress/components';

const { Fill, Slot } = createSlotFill( 'PluginTemplateSettingPanel' );

const PluginTemplateSettingPanel = Fill;
const PluginTemplateSettingPanel = ( { children } ) => {
const isCurrentEntityTemplate = useSelect(
( select ) =>
select( editorStore ).getCurrentPostType() === 'wp_template',
[]
);
if ( ! isCurrentEntityTemplate ) {
return null;
}
return <Fill>{ children }</Fill>;
};

PluginTemplateSettingPanel.Slot = Slot;

/**
Expand Down
2 changes: 0 additions & 2 deletions packages/edit-site/src/components/sidebar-edit-mode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { STORE_NAME } from '../../store/constants';
import SettingsHeader from './settings-header';
import PagePanels from './page-panels';
import TemplatePanel from './template-panel';
import PluginTemplateSettingPanel from '../plugin-template-setting-panel';
import { SIDEBAR_BLOCK, SIDEBAR_TEMPLATE } from './constants';
import { store as editSiteStore } from '../../store';
import { unlock } from '../../lock-unlock';
Expand Down Expand Up @@ -96,7 +95,6 @@ const FillContents = ( {
focusable={ false }
>
{ isEditingPage ? <PagePanels /> : <TemplatePanel /> }
<PluginTemplateSettingPanel.Slot />
</Tabs.TabPanel>
<Tabs.TabPanel tabId={ SIDEBAR_BLOCK } focusable={ false }>
<InspectorSlot bubblesVirtually />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { privateApis as routerPrivateApis } from '@wordpress/router';
import { store as editSiteStore } from '../../../store';
import TemplateActions from '../../template-actions';
import TemplateAreas from './template-areas';
import PluginTemplateSettingPanel from '../../plugin-template-setting-panel';
import { useAvailablePatterns } from './hooks';
import { TEMPLATE_PART_POST_TYPE } from '../../../utils/constants';
import { unlock } from '../../../lock-unlock';
Expand Down Expand Up @@ -115,6 +116,7 @@ export default function TemplatePanel() {
>
<TemplateAreas />
</PostCardPanel>
<PluginTemplateSettingPanel.Slot />
{ availablePatterns?.length > 0 && (
<PanelBody
title={ __( 'Transform into:' ) }
Expand Down

0 comments on commit 7f6053f

Please sign in to comment.