Skip to content

fix(core): load the entry in the address when the editor moves to another one - #8110

Merged
martinjagodic merged 1 commit into
mainfrom
fix/editor-reload-on-entry-change
Dec 2, 2026
Merged

martinjagodic merged 1 commit into
mainfrom
fix/editor-reload-on-entry-change

Conversation

@martinjagodic

Copy link
Copy Markdown
Member

Summary

The editor loaded its entry only when it mounted. The router keeps it mounted when the address moves from one entry to another (an edited URL, the browser's back and forward buttons, a link pasted into an open admin tab), so the draft kept the previous entry. The editor then showed the previous entry's path, title and body under the new address, and a save would have written them there. Found while testing 3.19.0 on the tester: going from sink/entries/example to pages/entries/about/index showed the kitchen sink's data in the Pages editor.

The editor now loads the entry in the address when the draft holds a different one. It does what unmounting and mounting again would: it stops the previous entry's notes polling, flushes its pending backup, discards the draft, then retrieves the new entry's backup and loads it.

Its own redirects are left as they were: after saving a new entry, or after a save or publish that changes the slug, the editor loads the entry it is going to before it navigates, so the draft already matches the address.

Test plan

  • New unit tests: moving to another entry in the same collection, and to another collection, loads the entry in the address and doesn't back up the previous draft under it. A redirect whose entry is already loaded keeps the draft. The first two fail on main.
  • In the demo (test-repo backend, editorial workflow), with and without the fix:
Case main This branch
Address from one post to another Shows the first post Shows the second
Address from a post to a nested page Shows the post under Pages Shows the page
Unsaved edit, then the address moves The edit lands in the wrong entry Leave-page prompt, then the other entry loads clean
First save of a new page (redirect to its slug) Works Works, unchanged
Publishing a nested page with a new path (redirect to the new slug) Works Works, unchanged

…ther one

The router keeps the editor mounted when the address moves from one
entry to another, for example after editing the URL or going back in
the browser, and the editor loaded its entry only on mount. The draft
kept the previous entry, so the editor showed its path, title and body
under the new address, and saving would have written them there.

The editor now loads the entry in the address when the draft holds a
different one. Its own redirects, after saving a new entry or after a
save or publish that changes the slug, load the entry they lead to
first, so the draft already matches and they are left as they were.
@martinjagodic
martinjagodic requested a review from a team as a code owner December 2, 2026 15:30
@netlify

netlify Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for decap-cms ready!

Name Link
🔨 Latest commit 3047077
🔍 Latest deploy log https://app.netlify.com/projects/decap-cms/deploys/6b1039809108925e21b95404
😎 Deploy Preview https://deploy-preview-8110--decap-cms.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added the type: bug code to address defects in shipped code label Dec 2, 2026
@martinjagodic
martinjagodic merged commit 470e51c into main Dec 2, 2026
20 checks passed
@martinjagodic
martinjagodic deleted the fix/editor-reload-on-entry-change branch December 2, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug code to address defects in shipped code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant