Skip to content

Commit

Permalink
Fix for Post Editor
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Oct 31, 2024
1 parent aec7cba commit a43b176
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/block-library/src/query/test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ describe( 'Query block utils', () => {

describe( 'getQueryContextFromTemplate', () => {
it( 'should return the correct query context based on template slug', () => {
expect( getQueryContextFromTemplate() ).toStrictEqual( {
isSingular: true,
} );
expect( getQueryContextFromTemplate( '404' ) ).toStrictEqual( {
isSingular: true,
templateType: '404',
Expand Down
6 changes: 5 additions & 1 deletion packages/block-library/src/query/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,11 @@ export const useUnsupportedBlocks = ( clientId ) => {
* @param {string} templateSlug Current template slug based on context.
* @return {Object} An object with isSingular and templateType properties.
*/
export function getQueryContextFromTemplate( templateSlug = '' ) {
export function getQueryContextFromTemplate( templateSlug ) {
// In the Post Editor, the template slug is not available.
if ( ! templateSlug ) {
return { isSingular: true };
}
let isSingular = false;
let templateType = templateSlug === 'wp' ? 'custom' : templateSlug;
const singularTemplates = [ '404', 'blank', 'single', 'page', 'custom' ];
Expand Down

0 comments on commit a43b176

Please sign in to comment.