Repository navigation
Description
Description
With real-time collaboration enabled, opening the pre-publish panel makes the Publish button turn into "Save" a moment later, and the post appears permanently dirty:
- Click Publish. The pre-publish panel opens and looks fine, showing a "Publish" button.
- A second or two later the button silently changes to "Save".
- Reloading the page triggers the "Changes you made may not be saved" browser warning, even though the user made no further edits.
- Clicking Cancel closes the panel, but the header button stays "Save" and never returns to "Publish".
- Clicking "Save" does publish the post.
This happens with any post content. It is not caused by the pre-publish panel itself; the panel is just the first common UI that resolves a single taxonomy term record (MaybeCategoryPanel resolves the default category to decide whether to suggest assigning a category).
Root cause
Resolving any synced taxonomy record spuriously marks it as having edits. Merely running wp.data.select( 'core' ).getEntityRecord( 'taxonomy', 'category', 1 ) with collaboration active makes taxonomy/category/1 dirty about one HTTP-polling round trip (~1-2s) later, with the entire term record (including _links, meta, count, ...) stored as edits. hasNonPostEntityChanges() then returns true, which flips the publish button label to "Save" (packages/editor/src/components/post-publish-button/label.js).
The chain:
- All taxonomy entities are sync-enabled with
defaultSyncConfig(packages/core-data/src/entities.js). - The
getEntityRecordresolver loads the record into the sync manager (packages/core-data/src/resolvers.js). The HTTP-polling provider exchanges document updates with the server. - When a remote update for the term document arrives (from another tab/peer, or state relayed by the server from a previous session), the sync manager calls
syncConfig.getChangesFromCRDTDoc( ydoc, editedRecord )to compute which properties changed (packages/sync/src/manager.ts,_updateEntityRecord). defaultGetChangesFromCRDTDocignores theeditedRecordargument and returns the entire CRDT record map (packages/core-data/src/utils/crdt.ts):The post-specificfunction defaultGetChangesFromCRDTDoc( crdtDoc: CRDTDoc ): ObjectData { return getRootMap( crdtDoc, CRDT_RECORD_MAP_KEY ).toJSON(); }
getPostChangesFromCRDTDocdeep-compares each property against the edited record and only returns real changes; the default config does no comparison at all.- The sync manager dispatches the full record as edits via the raw
EDIT_ENTITY_RECORDhandler in the resolver, which bypasses theeditEntityRecordaction creator, so nothing filters out unchanged values. Every property of the term (fresh object identities fromY.Map.toJSON()) is stored as an edit, and the record is dirty from then on.
Because the "edits" are just an echo of the record itself, nothing the user does clears them, which is why Cancel never restores the Publish button.
Step-by-step reproduction instructions
- Enable real-time collaboration (e.g. WordPress trunk + Gutenberg trunk,
wp_collaboration_enabledoption set, which is the default on plugin activation when allowed). - Open any post in the editor in two browser sessions (two tabs is enough), or use a site where an editor session previously ran with collaboration active.
- In both sessions, click Publish so the pre-publish panel opens (this resolves the default category record).
- Watch the pre-publish panel button in the first session: within a couple of seconds it changes from "Publish" to "Save".
- In the console,
wp.data.select( 'core' ).__experimentalGetDirtyEntityRecords()showstaxonomy/category/1dirty, with the whole term record as edits.
A minimal console-only reproduction (single session, when the server already has relayed state for the term document):
wp.data.select( 'core' ).getEntityRecord( 'taxonomy', 'category', 1 );
// ~1-2 seconds later:
wp.data.select( 'core' ).hasEditsForEntityRecord( 'taxonomy', 'category', 1 ); // trueExpected behaviour
Resolving an entity record must not create entity edits. The Publish button should stay "Publish", and no beforeunload warning should appear for changes the user never made.
Impact
- Confusing publish flow (Publish turns into Save, post looks unsaved, reload warning).
- Clicking "Save" saves the spuriously dirty term along with the post, issuing a needless
POST /wp/v2/categories/1request. For roles withoutmanage_categoriesthat request fails. - Affects every entity kind that uses
defaultSyncConfig, i.e. all taxonomies.
Environment
- Gutenberg trunk (also reproducible on earlier versions; unrelated to any recent media change, despite first being noticed right after Image: sideload external images on the server when uploading to the library #79409 merged)
- WordPress trunk with real-time collaboration enabled
- Does not reproduce when
window._wpCollaborationEnabledis falsy
Origin
The defective function was introduced in 87806a9dc8c ("Improve entity sync configs", #72145), which added defaultGetChangesFromCRDTDoc returning the whole CRDT record map without comparing against the edited record.
It became reachable for taxonomy terms in 3ac9c028144 ("Real-time collaboration: Sync collections", #74665), which assigned defaultSyncConfig to all taxonomy entities. c4e4fac0a26 (#75699) later removed the IS_GUTENBERG_PLUGIN gate on that assignment, widening exposure to all builds.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fields✅ Done
Activity
adamziel commentedon Jul 6, 2026
Nice timing, I was about to open a new issue for this. Here's the description I prepared for mine:
When collaboration is enabled, the post editor can show a category term as a pending save item even though the user did not change the category.
In my repro, I edited only the post title. The post category assignment stayed unchanged, but the save panel still listed both the post and
Categories → Musings:both-browser-windows-repro-post-36.mp4
Environment
7.023.5.0MusingsSteps to reproduce
Musings.Collaborators list, 2 online.Expected result
The save panel should list only the modified post.
Actual result
The save panel says there are 2 site changes waiting to be saved and lists:
Posts→ the edited postCategories→MusingsThe post category assignment remains unchanged. In my local repro:
Collaboration: only report changed properties from the default sync c…
adamsilverstein commentedon Jul 6, 2026
Great, thanks for confirming @adamziel! I came across this adding a pre-publish check for images inserted by URL (I first thought my change was somehow responsible for the bug, but it was more related to how I was testing the feature). I'm happy to hear this fixed a bug you had already encountered!
Collaboration: only report changed properties from the default sync c…