Skip to content

Commit

Permalink
Hold the PostContent block render until userCanEdit status loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
WunderBart committed Mar 1, 2023
1 parent 10d7c04 commit 8486b48
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/block-library/src/post-content/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ function EditableContent( { context = {} } ) {

function Content( props ) {
const { context: { queryId, postType, postId } = {} } = props;
const isDescendentOfQueryLoop = Number.isFinite( queryId );
const userCanEdit = useCanEditEntity( 'postType', postType, postId );
if ( userCanEdit === undefined ) {
return null;
}

const isDescendentOfQueryLoop = Number.isFinite( queryId );
const isEditable = userCanEdit && ! isDescendentOfQueryLoop;

return isEditable ? (
Expand Down

0 comments on commit 8486b48

Please sign in to comment.