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

Editor: Fix loading templates using a top level pattern block that includes a template part. #59900

Merged
merged 1 commit into from
Mar 15, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/editor/src/components/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export const ExperimentalEditorProvider = withRegistryProvider(
setRenderingMode( settings.defaultRenderingMode ?? 'post-only' );
}, [ settings.defaultRenderingMode, setRenderingMode ] );

useHideBlocksFromInserter( post.type );
useHideBlocksFromInserter( post.type, mode );

// Register the editor commands.
useCommands();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ const POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART = [
* the template part and post content blocks need to be hidden.
*
* @param {string} postType Post Type
* @param {string} mode Rendering mode
*/
export function useHideBlocksFromInserter( postType ) {
export function useHideBlocksFromInserter( postType, mode ) {
useEffect( () => {
/*
* Prevent adding template part in the editor.
Expand All @@ -32,7 +33,8 @@ export function useHideBlocksFromInserter( postType ) {
! POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(
postType
) &&
blockType.name === 'core/template-part'
blockType.name === 'core/template-part' &&
mode === 'post-only'
) {
return false;
}
Expand Down Expand Up @@ -77,5 +79,5 @@ export function useHideBlocksFromInserter( postType ) {
'removePostContentFromInserter'
);
};
}, [ postType ] );
}, [ postType, mode ] );
}
Loading