Conversation
There was a problem hiding this comment.
We should avoid returning new object references here. It will fail shallow equality check and cause unnecessary rerenders.
The postContentBlock calculation has guard clauses, so I think it's safe to return undefined. We can also use the EMPTY_OBJECT reference if that's preferred.
There was a problem hiding this comment.
It's also being given a default on line 119 where we destructure the return value of useSelect so I suppose we should remove that one too.
There was a problem hiding this comment.
Assigning default values during destructuring is okay; that doesn't change values returned inside the selector function.
|
Size Change: +20 B (0%) Total Size: 1.28 MB
ℹ️ View Unchanged
|
5b1c75b to
458f248
Compare
tellthemachines
left a comment
There was a problem hiding this comment.
Thanks for uncovering this bug!
Tested with author user and admin user, on both block and classic themes, and also checked the template editor. Everything is working fine ✅
I guess an outstanding issue here is that an author user isn't able to get the correct layout styles in the post editor, but that's something to be looked at separately.
There was a problem hiding this comment.
It's also being given a default on line 119 where we destructure the return value of useSelect so I suppose we should remove that one too.
|
Thanks for testing, @tellthemachines! Unfortunately, the incorrect layout issue remains for non-admin users. Maybe we can add the |
I just tried out an alternative approach to fetching the Post Content in #45299 which works for all user types. |
What?
This is a follow-up for #44258.
PR fixes permission errors triggered by
getEditedPostTemplatefor users with lower capabilities.Why?
The editor should check permission before making requests when data isn't available for everyone.
How?
Add check for user permissions before requesting
getEditedPostTemplate.Testing Instructions