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 rendering PluginTemplateSettingPanel when we're editing a template #60215

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move the slot below the "Transform into:" panel to retain the same position as on the trunk?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think not because initially was below the 'template card' and that changed unintentionally.. If someone reports something, we could revisit. The goal though would be to use PluginDocumentSettingPanel eventually.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense 👍

{ availablePatterns?.length > 0 && (
<PanelBody
title={ __( 'Transform into:' ) }
Expand Down