Skip to content

Block Library: Fix Tabs block losing added tabs when the editor is reopened#78250

Merged
talldan merged 3 commits into
WordPress:trunkfrom
Mustafabharmal:fix/tabs-block-added-tabs-disappear-78241
May 14, 2026
Merged

Block Library: Fix Tabs block losing added tabs when the editor is reopened#78250
talldan merged 3 commits into
WordPress:trunkfrom
Mustafabharmal:fix/tabs-block-added-tabs-disappear-78241

Conversation

@Mustafabharmal
Copy link
Copy Markdown
Contributor

What?

Tabs added beyond the initial two were silently deleted every time a saved page containing a Tabs block was opened for editing.

Closes #78241

Why?

TABS_TEMPLATE in tabs/edit.js specified nested inner blocks for core/tab-list (2 × core/tab) and core/tab-panels (2 × core/tab-panel). Because templateLock is 'all', the useInnerBlockTemplateSync hook always runs synchronizeBlocksWithTemplate on mount regardless of whether the block already has inner blocks.

synchronizeBlocksWithTemplate maps over the template entries, not the existing blocks, so it always produces exactly as many blocks as the template lists. A block saved with four tabs was reduced to two on every editor open, and the truncated state was persisted on the next save.

How?

Three minimal changes:

  1. tabs/edit.jsTABS_TEMPLATE now names only the two structural child blocks (core/tab-list, core/tab-panels) without inner block entries. When synchronizeBlocksWithTemplate processes these template entries it passes undefined as the inner block template, which causes the function to return the existing inner blocks unchanged (the early if ( ! template ) { return blocks; } guard).

  2. tab-panels/edit.jsTAB_PANELS_TEMPLATE is updated to create two labelled panels on initial insertion (matching the previous default). Because templateLock is false here, this template is only applied when the container is empty (new block), never to existing saved blocks.

  3. tab-list/edit.js — Now initializes with two tab buttons by default, so the Tabs menu is always visible on first insert.

Testing Instructions

  1. Insert a Tabs block (Gutenberg Experiments → Experimental Blocks must be enabled).
  2. Add at least two additional tabs (3+ total) via the block toolbar.
  3. Add content to each tab panel.
  4. Publish / save the page.
  5. Reload the editor.
  6. Before fix: only the first two tabs remain. After fix: all tabs and their content are preserved.
  7. Also verify that inserting a brand-new Tabs block still starts with two tabs.

Screenshots or screencast

Before:

Before.Tab.Fix.mov

After:

After.Tab.Fix.mov

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 13, 2026

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: Mustafabharmal <[email protected]>
Co-authored-by: talldan <[email protected]>
Co-authored-by: joemaller <[email protected]>

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

@github-actions github-actions Bot added the [Package] Block library /packages/block-library label May 13, 2026
@joemaller
Copy link
Copy Markdown
Contributor

Thanks for the quick fix @Mustafabharmal !

@talldan talldan added the [Type] Bug An existing feature does not function as intended label May 14, 2026
Copy link
Copy Markdown
Contributor

@talldan talldan left a comment

Choose a reason for hiding this comment

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

This fixes things for me. Thanks!

@talldan talldan added the props-bot Manually triggers Props Bot to ensure the list of props is up to date. label May 14, 2026
@github-actions github-actions Bot removed the props-bot Manually triggers Props Bot to ensure the list of props is up to date. label May 14, 2026
@talldan talldan enabled auto-merge (squash) May 14, 2026 01:47
@talldan talldan merged commit 8965255 into WordPress:trunk May 14, 2026
55 of 57 checks passed
@github-actions github-actions Bot added this to the Gutenberg 23.3 milestone May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tabs Block: Added tabs disappear, lost content

3 participants