payloadcms / payloadcms/payload
Autosave can overwrite recently typed field values and reload the media library
- Dominant language
- TypeScript
- Stars
- 44.8k
- Forks
- 4.2k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 53
Description
Describe the Bug
When editing a draft in the Payload admin, autosave can overwrite recently typed field values.
If we start typing in one field, move to another field, and continue typing before the previous autosave request has completed, text in the first field sometimes reverts to its earlier value.
A related issue occurs with the media library: if we edit a field and quickly open the media library before autosave completes, the media picker flickers and appears to reload.
This makes creating page layouts frustrating, because editors need to wait for autosave to finish between edits to avoid losing input or having the media library refresh.
We have also tested longer autosave intervals, including 800ms and 1000ms. The issue still occurs; a longer interval only changes how easy it is to trigger.
Videos:
https://github.com/user-attachments/assets/e8316c85-fa88-4d9b-986c-4c91dd15c75f
https://github.com/user-attachments/assets/da9f6674-970b-4b82-9dbb-953d599e02e4
Link to the code that reproduces this issue
https://github.com/beyondwebb/payload-issue/tree/autosave-reproduction
Reproduction Steps
-
Create a collection with drafts and autosave enabled:
versions: { drafts: { autosave: { interval: 100, }, }, }, -
Open a document in the admin panel and begin editing it.
-
Type text into a text field.
-
Immediately move to another field and continue typing while the first autosave is still pending.
-
Observe that the first field may lose some of the entered text.
To reproduce the media picker issue:
-
Edit a field in a draft-enabled document.
-
Before autosave finishes, open an upload/media field and wait for the loading screen to finish.
-
Observe that the media library reloads during the interaction.
Which area(s) are affected?
area: ui
Environment Info
Payload: 3.87.0, Next.js: 15.4.11, Node.js: v20.9.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the autosave reproduction branch linked in the issue and reproduce the draft editing and media-picker sequences using the shown 100ms autosave configuration. Trace the admin panel's pending autosave behavior while switching fields or opening media, then verify that recently typed values remain intact and the media library does not reload during the interaction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- next.js, react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100