diff --git a/packages/editor/src/components/post-actions/actions.js b/packages/editor/src/components/post-actions/actions.js index 4887a3031a7e0..8ab7435c475a8 100644 --- a/packages/editor/src/components/post-actions/actions.js +++ b/packages/editor/src/components/post-actions/actions.js @@ -687,7 +687,10 @@ const duplicatePostAction = { }; const isTemplatePartRevertable = ( item ) => { - const hasThemeFile = item.templatePart.has_theme_file; + if ( ! item ) { + return false; + } + const hasThemeFile = item.templatePart?.has_theme_file; return canDeleteOrReset( item ) && hasThemeFile; }; @@ -1020,8 +1023,12 @@ export const deletePatternAction = { id: 'delete-pattern', label: __( 'Delete' ), isEligible: ( item ) => { + if ( ! item ) { + return false; + } const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE; - const hasThemeFile = isTemplatePart && item.templatePart.has_theme_file; + const hasThemeFile = + isTemplatePart && item.templatePart?.has_theme_file; return canDeleteOrReset( item ) && ! hasThemeFile; }, hideModalHeader: true, diff --git a/packages/editor/src/components/post-actions/export-pattern-action.js b/packages/editor/src/components/post-actions/export-pattern-action.js index 16d03150bc5cf..7b344e2c42a77 100644 --- a/packages/editor/src/components/post-actions/export-pattern-action.js +++ b/packages/editor/src/components/post-actions/export-pattern-action.js @@ -36,7 +36,12 @@ export const exportPatternAsJSONAction = { id: 'export-pattern', label: __( 'Export as JSON' ), supportsBulk: true, - isEligible: ( item ) => item.type === PATTERN_TYPES.user, + isEligible: ( item ) => { + if ( ! item.type ) { + return false; + } + return item.type === PATTERN_TYPES.user + }, callback: async ( items ) => { if ( items.length === 1 ) { return downloadBlob(