Skip to content
Open
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
20 changes: 17 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,17 @@ const withQueryLoopContextProvider = createHigherOrderComponent(
);
}
);
return childPostTemplatesClientIds.map( getBlock );
// Filter out any null results: getBlock() can transiently
// return null during the site editor's initial block-tree
// construction (e.g. when a pattern block's inner blocks are
// registered in the name index before their full record lands
// in byClientId). Leaving nulls in the array crashes the
// consuming HOCs (withPostTemplateStyles,
// withPostTemplateInspectorControls) when they access
// postTemplate.clientId.
return childPostTemplatesClientIds
.map( getBlock )
.filter( Boolean );
},
[ clientId ]
);
Expand Down Expand Up @@ -551,13 +561,17 @@ const withPostTemplateStyles = createHigherOrderComponent( ( BlockEdit ) => {
`
: '';

const hideAfterLimit = `
// Only inject the after-limit rule when perPage is known; without it
// the expression evaluates to NaN and produces an invalid selector.
const hideAfterLimit = perPage
? `
${ blockSelector } :is(.wp-block-post:not([style*="display: none"])):nth-of-type(n+${
offset + perPage + 2
}) {
display: none !important;
}
`;
`
: '';

// When a subsequent post-template is shown with a positive offset, the initial dropzone placeholder
// and hidden preview block cause the CSS hiding to be off by one. Each post template actually contains
Expand Down
Loading