payloadcms / payloadcms/payload

Autosave is not compatible with Folders - New documents cannot be created in folders

Open
#16,028 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: core invalid-reproduction stale status: needs-triage
Dominant language
TypeScript
Stars
44.8k
Forks
4.2k
Avg merge
2d 21h
Merged PRs (30d)
53

Description

Describe the Bug

When auto save is enabled on a collection that supports folders, it causes an issue when you attempt to create a new document from an existing folder. As soon as you start editing the document it will autosave and return you to the folder index.

Expected behaviour: When using Auto save and creating a document from a folder the user remains on the edit page whilst auto save happens in the background.

Actual Behaviour: When the user starts editing they are unexpectedly exited from the edit screen.

Link to the code that reproduces this issue

https://github.com/tkgdbowen/payload-autosave-folder-issue

This is a minimal repo on the blank create-payload-app, see single change for collection setup here:
https://github.com/tkgdbowen/payload-autosave-folder-issue/commit/e10afb84a434955f6ff4eeeeaf3a5995308f517f

Reproduction Steps
  1. Create a new payload app using the website template
    pnpx create-payload-app@latest
  2. In payload.config.ts enable the folders feature
    buildConfig({ folders: {}, ... })
  3. Enable to folders feature on the pages collection in src\collections\Pages\index.ts, the versions feature is already enabled by default.
    export const Pages: CollectionConfig<'pages'> = {
      folders: true,
      versions: {
        drafts: {
          autosave: {
            interval: 100
          }
        }
      }
      ...
    }
    
  4. Run the app pnpm run dev
  5. Click Browse by Folder
  6. Create a new folder called "Test"
  7. Browse in to the new folder
  8. Create new Page
  9. Begin typing the page Title
  10. Observe that the page auto saves as soon as the first character is typed and the user is returned to the folder index.
Which area(s) are affected?

area: core

Environment Info
Binaries:
  Node: 24.14.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  payload: 3.80.0
  next: 15.4.11
  @payloadcms/db-postgres: 3.80.0
  @payloadcms/drizzle: 3.80.0
  @payloadcms/graphql: 3.80.0
  @payloadcms/live-preview: 3.80.0
  @payloadcms/live-preview-react: 3.80.0
  @payloadcms/next/utilities: 3.80.0
  @payloadcms/plugin-form-builder: 3.80.0
  @payloadcms/plugin-nested-docs: 3.80.0
  @payloadcms/plugin-redirects: 3.80.0
  @payloadcms/plugin-search: 3.80.0
  @payloadcms/plugin-seo: 3.80.0
  @payloadcms/richtext-lexical: 3.80.0
  @payloadcms/translations: 3.80.0
  @payloadcms/ui/shared: 3.80.0
  react: 19.2.1
  react-dom: 19.2.1
Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 65221
  Available CPU cores: 20

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the linked minimal repository, starting with payload.config.ts and src/collections/Pages/index.ts, then run pnpm run dev and follow the folders and autosave behavior. Done means creating a page inside a folder, typing in it, and remaining on the edit page while autosave runs instead of returning to the folder index.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.