payloadcms / payloadcms/payload
[v3] "Create New" form immediately closes/redirects after leaving a dirty form via "Leave anyway"
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 44.8k
- Forks
- 4.2k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 53
Description
Describe the Bug
Note: This is a core routing bug reproducible on a completely fresh install of the standard blank template.
In the Payload v3 Admin UI, when a user modifies a document and then attempts to navigate away via the sidebar, the Leave without saving modal correctly intercepts the navigation. However, if the user confirms by clicking "Leave anyway" and is routed to a collection's list view, the internal state of the interceptor (or Next.js router state) is not properly cleared.
If the user then immediately clicks the "Create New" button on that list view, the /create view attempts to mount but is instantly aborted or redirected back to the list view (effectively making it look like the form "quickly closes" or refuses to open).
A manual browser refresh (F5) on the list view clears this broken in-memory state, allowing the "Create New" button to function normally again.
Expected Behavior
Clicking "Leave anyway" should completely reset the useLeaveWithoutSaving routing state so that subsequent UI navigations (like clicking "Create New") process normally without triggering an unintended closure or redirect.
Link to the code that reproduces this issue
https://github.com/payloadcms/payload/tree/main/templates/blank
Reproduction Steps
- Go to the CMS Admin panel and log in.
- Navigate to a collection (e.g.,
Users) and enter theCreateorEditview. - Make a change to the form or trigger a validation error (e.g., click
Savewith missing required fields) so the form is marked as "dirty" (modified). - Click on the
Userscollection link from the left-side navigation menu. - The
Leave without changesmodal will appear. - Click the "Leave anyway" button. You will be routed to the
Userslist view. - Click the "Create New" button on the list view.
- Observe: The form attempts to open but quickly closes/redirects back to the list view. The user is unable to create a new record unless they refresh the page.
Which area(s) are affected?
area: ui
Environment Info
Payload Version: 3.81.0 (Also reproduced on 3.85.1)
Next.js Version: 15.0.0
---
Binaries:
Node: 22.17.0
npm: 10.9.2
Yarn: 1.22.22
pnpm: N/A
Relevant Packages:
payload: 3.81.0
next: 16.2.1
@payloadcms/db-postgres: 3.81.0
@payloadcms/drizzle: 3.81.0
@payloadcms/graphql: 3.81.0
@payloadcms/next/utilities: 3.81.0
@payloadcms/plugin-cloud-storage: 3.81.0
@payloadcms/plugin-multi-tenant: 3.81.0
@payloadcms/plugin-nested-docs: 3.81.0
@payloadcms/richtext-lexical: 3.81.0
@payloadcms/storage-s3: 3.81.0
@payloadcms/translations: 3.81.0
@payloadcms/ui/shared: 3.81.0
react: 19.2.1
react-dom: 19.2.1
Operating System:
Platform: linux
Arch: x64
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
Reproduce the navigation sequence in the templates/blank app, then trace the useLeaveWithoutSaving state through the sidebar transition and the collection list's Create New route. Check the Next.js router state after clicking "Leave anyway"; done means the create view remains open and usable without a browser refresh.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nextjs, react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100