Block Library: Fix Tabs block losing added tabs when the editor is reopened#78250
Merged
talldan merged 3 commits intoMay 14, 2026
Merged
Conversation
|
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. |
Contributor
|
Thanks for the quick fix @Mustafabharmal ! |
talldan
approved these changes
May 14, 2026
Contributor
talldan
left a comment
There was a problem hiding this comment.
This fixes things for me. Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_TEMPLATEintabs/edit.jsspecified nested inner blocks forcore/tab-list(2 ×core/tab) andcore/tab-panels(2 ×core/tab-panel). BecausetemplateLockis'all', theuseInnerBlockTemplateSynchook always runssynchronizeBlocksWithTemplateon mount regardless of whether the block already has inner blocks.synchronizeBlocksWithTemplatemaps 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:
tabs/edit.js—TABS_TEMPLATEnow names only the two structural child blocks (core/tab-list,core/tab-panels) without inner block entries. WhensynchronizeBlocksWithTemplateprocesses these template entries it passesundefinedas the inner block template, which causes the function to return the existing inner blocks unchanged (the earlyif ( ! template ) { return blocks; }guard).tab-panels/edit.js—TAB_PANELS_TEMPLATEis updated to create two labelled panels on initial insertion (matching the previous default). BecausetemplateLockisfalsehere, this template is only applied when the container is empty (new block), never to existing saved blocks.tab-list/edit.js— Now initializes with two tab buttons by default, so the Tabs menu is always visible on first insert.Testing Instructions
Screenshots or screencast
Before:
Before.Tab.Fix.mov
After:
After.Tab.Fix.mov