Skip to content

Commit

Permalink
fix: Preserve pdModal in state on replaceInitialState
Browse files Browse the repository at this point in the history
When Naja calls the `replaceInitialState` function, we have to keep the `pdModal` from the current window state. This only needs to be done on the `replaceInitialState` call.

Closes #1
  • Loading branch information
zipper committed May 28, 2024
1 parent 00616a9 commit cdcefb1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/extensions/AjaxModalExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ export class AjaxModalExtension implements Extension {
// will also be true, but it is probably the desired behaviour to save this state as non-modal anyway, since
// the initial state should (or could) never be opened in a modal.
if (operation === 'replaceState' && state.cursor === 0) {
// If there already is `pdModal` configuration in history state, we need to preserve that configuration.
if (window.history.state?.pdModal) {
state.pdModal = window.history.state.pdModal
}

return
}

Expand Down

0 comments on commit cdcefb1

Please sign in to comment.