Skip to content

Commit

Permalink
Editor: Fix loading templates using a top level pattern block that in…
Browse files Browse the repository at this point in the history
…cludes a template part (#59900)
  • Loading branch information
youknowriad authored Mar 15, 2024
1 parent 4dd6ffb commit d9326f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
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 ] );
}

0 comments on commit d9326f0

Please sign in to comment.