Skip to content

Collaboration: resolving a synced taxonomy record marks it dirty, turning the Publish button into "Save" #79907

Closed

Description

@adamsilverstein

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:

  1. Click Publish. The pre-publish panel opens and looks fine, showing a "Publish" button.
  2. A second or two later the button silently changes to "Save".
  3. Reloading the page triggers the "Changes you made may not be saved" browser warning, even though the user made no further edits.
  4. Clicking Cancel closes the panel, but the header button stays "Save" and never returns to "Publish".
  5. 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:

  1. All taxonomy entities are sync-enabled with defaultSyncConfig (packages/core-data/src/entities.js).
  2. The getEntityRecord resolver loads the record into the sync manager (packages/core-data/src/resolvers.js). The HTTP-polling provider exchanges document updates with the server.
  3. 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).
  4. defaultGetChangesFromCRDTDoc ignores the editedRecord argument and returns the entire CRDT record map (packages/core-data/src/utils/crdt.ts):
    function defaultGetChangesFromCRDTDoc( crdtDoc: CRDTDoc ): ObjectData {
        return getRootMap( crdtDoc, CRDT_RECORD_MAP_KEY ).toJSON();
    }
    The post-specific getPostChangesFromCRDTDoc deep-compares each property against the edited record and only returns real changes; the default config does no comparison at all.
  5. The sync manager dispatches the full record as edits via the raw EDIT_ENTITY_RECORD handler in the resolver, which bypasses the editEntityRecord action creator, so nothing filters out unchanged values. Every property of the term (fresh object identities from Y.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

  1. Enable real-time collaboration (e.g. WordPress trunk + Gutenberg trunk, wp_collaboration_enabled option set, which is the default on plugin activation when allowed).
  2. 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.
  3. In both sessions, click Publish so the pre-publish panel opens (this resolves the default category record).
  4. Watch the pre-publish panel button in the first session: within a couple of seconds it changes from "Publish" to "Save".
  5. In the console, wp.data.select( 'core' ).__experimentalGetDirtyEntityRecords() shows taxonomy/category/1 dirty, 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 ); // true

Expected 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/1 request. For roles without manage_categories that request fails.
  • Affects every entity kind that uses defaultSyncConfig, i.e. all taxonomies.

Environment

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.

Activity

  1. moved this to 📋 Iteration/Tracking Issues in WordPress 7.1 Editor Taskson Jul 6, 2026
  2. moved this from 📋 Iteration/Tracking Issues to 🏗️ In Progress in WordPress 7.1 Editor Taskson Jul 6, 2026
  3. adamziel commented on Jul 6, 2026

    @adamziel
    Contributor

    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

    • WordPress core: 7.0
    • Gutenberg plugin: 23.5.0
    • Collaboration enabled
    • Same post open in two editor sessions
    • Post assigned to category: Musings

    Steps to reproduce

    1. Enable collaboration.
    2. Create or open a post assigned to a category, e.g. Musings.
    3. Open the same post editor in two browser windows/tabs.
    4. Wait until the editor shows Collaborators list, 2 online.
    5. In one window, edit only the post title.
    6. Do not touch the Categories panel or category checkbox.
    7. Click Save.

    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 post
    • Categories → Musings

    The post category assignment remains unchanged. In my local repro:

    "postCategories": [2]
  4. added a commit that references this issue on Jul 6, 2026
    8d7d31b
  5. moved this from 🏗️ In Progress to ✅ Done in WordPress 7.1 Editor Taskson Jul 6, 2026
  6. adamsilverstein commented on Jul 6, 2026

    @adamsilverstein
    MemberAuthor

    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!

  7. added a commit that references this issue on Jul 8, 2026
    c4f0156
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

[Feature] Real-time CollaborationPhase 3 of the Gutenberg roadmap around real-time collaboration[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions