Skip to content

Commit

Permalink
Site Editor: Fix template part area listing when a template has no ed…
Browse files Browse the repository at this point in the history
…its (#55115)

* Alternative: Fix template part area listing when a template has no edits
* Fix typos
  • Loading branch information
Mamaduka authored and mikachan committed Oct 9, 2023
1 parent 2e4bba1 commit 95e1f62
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions packages/edit-site/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,22 +292,21 @@ export function isSaveViewOpened( state ) {
* @return {Array} Template parts and their blocks in an array.
*/
export const getCurrentTemplateTemplateParts = createRegistrySelector(
( select ) => ( state ) => {
const templateType = getEditedPostType( state );
const templateId = getEditedPostId( state );
const template = select( coreDataStore ).getEditedEntityRecord(
'postType',
templateType,
templateId
);

( select ) => () => {
const templateParts = select( coreDataStore ).getEntityRecords(
'postType',
TEMPLATE_PART_POST_TYPE,
{ per_page: -1 }
);

return getFilteredTemplatePartBlocks( template.blocks, templateParts );
const clientIds =
select( blockEditorStore ).__experimentalGetGlobalBlocksByName(
'core/template-part'
);
const blocks =
select( blockEditorStore ).getBlocksByClientId( clientIds );

return getFilteredTemplatePartBlocks( blocks, templateParts );
}
);

Expand Down

0 comments on commit 95e1f62

Please sign in to comment.