Skip to content

fix: Set historyEnabled only when modal state is pushed in AjaxModalExtension - #52

Merged
zipper merged 1 commit into
masterfrom
fix/ajax-modal-history
May 14, 2026
Merged

zipper merged 1 commit into
masterfrom
fix/ajax-modal-history

Conversation

@zipper

@zipper zipper commented May 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 🐛 historyEnabled was set unconditionally to true in buildState, leaking across unrelated naja requests
  • Now mirrors isShown — the flag is only enabled when a modal state was actually pushed/replaced

Why

Unrelated naja requests using data-naja-history="replace" would leave historyEnabled = true, and hiddenHandler would then call history.back() when a non-ajax modal was closed — navigating the user out of the page.

Test plan

  • CI checks
  • Manuální ověření: stránka s data-naja-history="replace" requestem + non-ajax modal — zavření modalu nesmí způsobit navigaci pryč
  • Standardní AJAX modal flow (otevření/zavření) stále funguje včetně history.back()

…alExtension`

Previously `historyEnabled` was set unconditionally to `true` in `buildState`, so unrelated naja
requests using `data-naja-history="replace"` would mark history as enabled and later trigger
`history.back()` from `hiddenHandler` when a non-ajax modal was closed, navigating the user
out of the page. Now the flag mirrors `isShown`, matching whether a modal state was actually
pushed/replaced.
@zipper
zipper merged commit 59557ee into master May 14, 2026
1 of 2 checks passed
@zipper
zipper deleted the fix/ajax-modal-history branch May 14, 2026 10:34
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.

1 participant