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

Alternative: Fix template part area listing when a template has no edits #55115

Merged
merged 2 commits into from
Oct 9, 2023
Merged
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
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
Loading