payloadcms / payloadcms/payload

Leave without saving warning missing when using browser navigation

Open
#14,957 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: core area: ui Bug 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 creating a new collection item and using the browser's Back button, the warning about unsaved changes does not appear. However, this warning is displayed when navigating using a UI link (e.g., another collection or a breadcrumb link).

Not sure why previous issue was closed as duplicate (didn't find any issue like this) - https://github.com/payloadcms/payload/issues/14854

Link to the code that reproduces this issue

https://github.com/payloadcms/payload/tree/main/templates/website

Reproduction Steps

Go to a collection with autosave disabled (ex. users)
Create new item
Type at least one character in input field
Hit back button
Browser navigates back
Expected behavior: "Leave without saving" warning should be displayed

Image
Which area(s) are affected?

area: ui, area: core

Environment Info
Binaries:
  Node: 20.19.0
  npm: 10.8.2
  Yarn: N/A
  pnpm: 10.3.0
Relevant Packages:
  payload: 3.67.0
  next: 15.4.4
  @payloadcms/db-sqlite: 3.67.0
  @payloadcms/drizzle: 3.67.0
  @payloadcms/email-nodemailer: 3.67.0
  @payloadcms/graphql: 3.67.0
  @payloadcms/live-preview: 3.67.0
  @payloadcms/live-preview-react: 3.67.0
  @payloadcms/next/utilities: 3.67.0
  @payloadcms/payload-cloud: 3.67.0
  @payloadcms/plugin-seo: 3.67.0
  @payloadcms/richtext-lexical: 3.67.0
  @payloadcms/translations: 3.67.0
  @payloadcms/ui/shared: 3.67.0
  react: 19.1.0
  react-dom: 19.1.0
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:25 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6020
  Available memory (MB): 16384
  Available CPU cores: 10

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

Start with the templates/website reproduction and verify the behavior on a collection with autosave disabled: create an item, edit a field, and use the browser Back button. Compare this with navigation through a collection or breadcrumb link; the work is done when both navigation paths show the “Leave without saving” warning for unsaved changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js, react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.