Skip to content

[6.x] Don't show unsaved changes warning when switching tabs#14678

Merged
jasonvarga merged 1 commit into
6.xfrom
fix-tab-switch-dirty-state-warning
May 15, 2026
Merged

[6.x] Don't show unsaved changes warning when switching tabs#14678
jasonvarga merged 1 commit into
6.xfrom
fix-tab-switch-dirty-state-warning

Conversation

@jasonvarga
Copy link
Copy Markdown
Member

Fixes #14676, introduced by #14592.

What

When switching tabs on an entry edit form, Statamic updates the URL hash (e.g. /entries/1#tab-2) to remember the active tab. This adds entries to the browser history stack. Navigating back through those hash entries fires a popstate event, which the listener added in #14592 was incorrectly treating as a full page navigation — showing the "unsaved changes" dialog even though the user never left the page.

Fix

In the popstate handler, before showing the warning, compare the destination URL's pathname and search query against the dirty URL's. If only the hash differs (same path and query), the navigation is in-page tab switching — skip the warning and let the browser handle it normally.

Also updated the existing tests to properly simulate the URL already being at the destination when popstate fires (matching real browser behaviour), and added a test covering the hash-only case.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jasonvarga jasonvarga merged commit 1f04e1c into 6.x May 15, 2026
18 checks passed
@jasonvarga jasonvarga deleted the fix-tab-switch-dirty-state-warning branch May 15, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unsaved changes alert when switching between tabs

1 participant