Skip to content

Commit

Permalink
Avoid white page on publish
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Nov 30, 2023
1 parent 0327e80 commit bafdc95
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/edit-post/src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ function Editor( { postId, postType, settings, initialEdits, ...props } ) {
hiddenBlockTypes,
blockTypes,
keepCaretInsideBlock,
hasTemplate,
template,
} = useSelect(
( select ) => {
Expand Down Expand Up @@ -67,8 +66,6 @@ function Editor( { postId, postType, settings, initialEdits, ...props } ) {
getEditorSettings().supportsTemplateMode;
const isViewable = getPostType( postType )?.viewable ?? false;
const canEditTemplate = canUser( 'create', 'templates' );
const _hasTemplate =
supportsTemplateMode && isViewable && canEditTemplate;

return {
hasFixedToolbar: isFeatureActive( 'fixedToolbar' ),
Expand All @@ -82,8 +79,10 @@ function Editor( { postId, postType, settings, initialEdits, ...props } ) {
hiddenBlockTypes: getHiddenBlockTypes(),
blockTypes: getBlockTypes(),
keepCaretInsideBlock: isFeatureActive( 'keepCaretInsideBlock' ),
hasTemplate: _hasTemplate,
template: _hasTemplate ? getEditedPostTemplate() : null,
template:
supportsTemplateMode && isViewable && canEditTemplate
? getEditedPostTemplate()
: null,
post: postObject,
};
},
Expand Down Expand Up @@ -143,7 +142,7 @@ function Editor( { postId, postType, settings, initialEdits, ...props } ) {
keepCaretInsideBlock,
] );

if ( ! post || ( hasTemplate && ! template ) ) {
if ( ! post ) {
return null;
}

Expand Down

0 comments on commit bafdc95

Please sign in to comment.