Tabs block keeps post in dirty state after reload without any user changes
Description
The core/tabs block marks the editor as having unsaved changes immediately after reloading a saved post, even when the user has not modified anything.
This causes the editor to show the "Save draft" button instead of the normal "Saved" state with the checkmark indicator that other core blocks display.
The serialized content remains unchanged, but the editor still considers the post edited after loading a post containing a Tabs block.
Step-by-step reproduction instructions
- Create a new post.
- Insert a
Tabsblock. - Save or publish the post.
- Reload the editor.
- Without making any changes, observe the editor state.
Actual behavior
- The editor shows the "Save draft" button.
- The post appears to have unsaved changes.
- Refreshing or navigating away may trigger the leave-page warning dialog.
Expected behavior
- The editor should remain clean after reload.
- The header should display the normal "Saved" state with the checkmark indicator.
- No save action should appear until the user actually edits the content.
Screenshots, screen recording, code snippet
The issue appears specific to the Tabs block and does not reproduce with other core blocks under the same conditions. The problem occurs after reloading a saved post containing a Tabs block, without any user interaction.
https://github.com/user-attachments/assets/e4c362ed-6466-4eef-896a-ea9380da45e4
Environment info
- WordPress: Trunk
- Gutenberg: Trunk / latest plugin version
- Browser: Chrome
- Theme: Twenty Twenty-Five
- Plugins: Only Gutenberg active
Please confirm that you have searched existing issues in the repo.
- [x] Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- [x] Yes
Please confirm which theme type you used for testing.
- [x] Block
- [ ] Classic
- [ ] Hybrid (e.g. classic with theme.json)
- [ ] Not sure
I've identified the root cause and am working on a fix.
The problem is in tabs/edit.js: a useEffect on mount calls setAttributes({ editorActiveTabIndex: activeTabIndex }) to initialize the editorActiveTabIndex attribute. Unlike similar calls in child blocks, this one does not use __unstableMarkNextChangeAsNotPersistent, so it gets recorded as a persistent edit and marks the post dirty on every load.
Since editorActiveTabIndex has "role": "local" (never serialized), it's always undefined after a reload. All consumers already fall back to activeTabIndex via ??, so the initialization is unnecessary. The fix is to simply remove the useEffect.
Will open a PR shortly.