Skip to content

Commit

Permalink
fix: Adding a pagehide listener to cover bases when unload becomes de…
Browse files Browse the repository at this point in the history
…precated (#298)
  • Loading branch information
cahirodoherty-learningpool authored Nov 15, 2023
1 parent f07a603 commit 177de84
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions js/adapt-stateful-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default class StatefulSession extends Backbone.Controller {
if (shouldCommitOnVisibilityChange) {
document.addEventListener('visibilitychange', this.onVisibilityChange);
}
$(window).on('beforeunload unload', this.endSession);
$(window).on('beforeunload unload pagehide', this.endSession);
}

async saveSessionState() {
Expand Down Expand Up @@ -261,7 +261,7 @@ export default class StatefulSession extends Backbone.Controller {
}

removeEventListeners() {
$(window).off('beforeunload unload', this.endSession);
$(window).off('beforeunload unload pagehide', this.endSession);
document.removeEventListener('visibilitychange', this.onVisibilityChange);
this.stopListening();
}
Expand Down
2 changes: 1 addition & 1 deletion required/log_output.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</script>
</head>

<body onload="onLoad();" onunload="onUnload();">
<body onload="onLoad();" onunload="onUnload();" onpagehide="onUnload();">
<div id="logDiv"></div>
</body>

Expand Down

0 comments on commit 177de84

Please sign in to comment.