Skip to content

Block Inspector: Disable the 'Edit original' button when the entity ID is missing - #81288

Merged
Mamaduka merged 1 commit into
trunkfrom
fix/missing-synced-block-edit-button
Aug 7, 2026
Merged

Block Inspector: Disable the 'Edit original' button when the entity ID is missing#81288
Mamaduka merged 1 commit into
trunkfrom
fix/missing-synced-block-edit-button

Conversation

@Mamaduka

@Mamaduka Mamaduka commented Aug 6, 2026

Copy link
Copy Markdown
Member

What?

Noticed while testing #81177.

PR simplifies IsolatedEditButton in 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 / isTemplatePartBlock and called onNavigateToEntityRecord from two places, with the template part ID guard buried inside the handler.

I've also migrated to the Stack component to resolve suppressed ESLint error.

Testing Instructions

  1. Open a post and switch to the code editor.
  2. Add synced pattern without ref - <!-- wp:block /-->.
  3. Switch back to visual.
  4. Confirm that Edit original is disabled.
  5. Repeat the same step with the missing template part.

Testing Instructions for Keyboard

Same.

Screenshots or screencast

CleanShot 2026-08-06 at 17 38 01

Use of AI Tools

Assisted by Grammarly 😄

@Mamaduka Mamaduka self-assigned this Aug 6, 2026
@Mamaduka
Mamaduka requested a review from ellatrix as a code owner August 6, 2026 13:44
@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Package] Block editor /packages/block-editor labels Aug 6, 2026
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

Size Change: +20 B (0%)

Total Size: 7.81 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 434 kB +20 B (0%)

compressed-size-action

@ramonjd ramonjd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spotting!

Before After
Image Image
Image Image

const blockAttributes = block?.attributes || {};
const { ref, theme, slug } = attributes;
const entityId = isTemplatePartBlock
? theme && slug && `${ theme }//${ slug }`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't have a strong opinion, I would like to keep current ternanry :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meet you in the carpark... 🥊

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seriously, no blocking comments here. Was just a question really

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka

Mamaduka commented Aug 7, 2026

Copy link
Copy Markdown
Member Author

Thanks for the review, @ramonjd!

@Mamaduka
Mamaduka merged commit 2cb64f7 into trunk Aug 7, 2026
60 of 64 checks passed
@Mamaduka
Mamaduka deleted the fix/missing-synced-block-edit-button branch August 7, 2026 06:38
@github-actions github-actions Bot added this to the Gutenberg 23.8 milestone Aug 7, 2026
amitraj2203 pushed a commit that referenced this pull request Aug 10, 2026
…D is missing (#81288)

Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
shail-mehta pushed a commit that referenced this pull request Aug 12, 2026
…D is missing (#81288)

Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block editor /packages/block-editor [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants