Skip to content

Block editor: fallback for unsynced pattern insertion - #81323

Open
yyppsk wants to merge 14 commits into
WordPress:trunkfrom
yyppsk:fix/81041-unsynced-pattern-insert
Open

yyppsk wants to merge 14 commits into
WordPress:trunkfrom
yyppsk:fix/81041-unsynced-pattern-insert

Conversation

@yyppsk

@yyppsk yyppsk commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

What?

Closes: #81041

Fixes the insertion of unsynced patterns when their content cannot be parsed into blocks.

Unsynced patterns now:

  • Insert their parsed blocks directly when parsed content is available.
  • Fall back to the core/block reference when an unsynced reusable pattern has no parsed blocks.
  • Preserve the original reusable pattern behavior for core/block items with a valid ref.
  • Avoid incorrectly wrapping child-only blocks, such as core/button, in a new core/buttons block.
  • Remain available in the pattern inserter when their root block has a single allowed parent block.

Why?

Unsynced patterns can contain malformed or incomplete block content. In these cases, the parser may return no blocks, causing the inserter to insert nothing.

How?

The unsynced pattern insertion paths now use the following behavior:

  1. For a core/block item with a valid ref, insert the reusable pattern block directly.
  2. For other unsynced items with parsed content, insert cloned or parsed blocks directly.
  3. When no parsed blocks are available, insert a fallback block using the original block name and attributes.
  4. Allow patterns containing a child-only root block to appear when its single parent block is allowed at the insertion location.
  5. Do not synthesize a parent block around the parsed unsynced content.

Testing Instructions

  1. Open a post or page in the block editor.
  2. Create or locate an unsynced pattern containing editable blocks.

As per original issue #81041

<!-- wp:button {"className":"ewww-button aligncenter"} -->
<div class="wp-block-button ewww-button aligncenter"><a class="wp-block-button__link wp-element-button" href="https://ewww.io/fake-link/" rel="">Fake Text!</a></div>
<!-- /wp:button -->
  1. Open the inserter and select the unsynced pattern.
  2. Confirm that the pattern content is inserted directly and remains editable.
Before ( Unable to add unsynced pattern ) After ( Able to add unsynced pattern )
image image

Use of AI Tools

Used the help of AI tool like GPT 5.5 for code review.

@github-actions github-actions Bot added the [Package] Block editor /packages/block-editor label Aug 7, 2026
@yyppsk
yyppsk force-pushed the fix/81041-unsynced-pattern-insert branch from 3aa931d to 3935335 Compare August 10, 2026 12:42
@github-actions github-actions Bot added [Package] Block library /packages/block-library [Package] Edit Site /packages/edit-site labels Aug 14, 2026
@github-actions github-actions Bot removed [Package] Block library /packages/block-library [Package] Edit Site /packages/edit-site labels Aug 24, 2026
@yyppsk yyppsk changed the title WIP - Block editor: fallback for unsynced pattern insertion Block editor: fallback for unsynced pattern insertion Aug 24, 2026
@yyppsk
yyppsk marked this pull request as ready for review August 24, 2026 13:24
@yyppsk
yyppsk requested a review from ellatrix as a code owner August 24, 2026 13:24
@github-actions

Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: [Package] Block editor.

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

🤖 PR meta 🤖

🎉 Props

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: yyppsk <pranjalpratapsingh@git.wordpress.org>
Co-authored-by: nosilver4u <nosilver4u@git.wordpress.org>

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

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

This branch has not been deployed

No deployments
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cannot insert unsynced pattern and similar synced pattern not visible in pattern inserter

1 participant