Block Inspector: Disable the 'Edit original' button when the entity ID is missing - #81288
Conversation
|
Size Change: +20 B (0%) Total Size: 7.81 MB 📦 View Changed
|
| const blockAttributes = block?.attributes || {}; | ||
| const { ref, theme, slug } = attributes; | ||
| const entityId = isTemplatePartBlock | ||
| ? theme && slug && `${ theme }//${ slug }` |
There was a problem hiding this comment.
This can produce ${ theme }//${ slug }, undefined (no theme), '' or false, right?
Would just returning id or undefined be more readable? Longer, admittedly.
let entityId;
if ( isTemplatePartBlock ) {
entityId = theme && slug ? `${ theme }//${ slug }` : undefined;
} else {
entityId = ref;
}There was a problem hiding this comment.
If you don't have a strong opinion, I would like to keep current ternanry :)
There was a problem hiding this comment.
Seriously, no blocking comments here. Was just a question really
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Thanks for the review, @ramonjd! |
…D is missing (#81288) Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
…D is missing (#81288) Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>




What?
Noticed while testing #81177.
PR simplifies
IsolatedEditButtonin the block inspector's "Edit contents" panel and disables the "Edit original" button when the target entity can't be resolved.The click handler branched on
isSyncedPattern/isTemplatePartBlockand calledonNavigateToEntityRecordfrom two places, with the template part ID guard buried inside the handler.I've also migrated to the
Stackcomponent to resolve suppressed ESLint error.Testing Instructions
ref-<!-- wp:block /-->.Testing Instructions for Keyboard
Same.
Screenshots or screencast
Use of AI Tools
Assisted by Grammarly 😄