Add beforeunload event to add confirmation dialog when leaving page (#6279)

This commit is contained in:
Hanusz Leszek 2024-09-29 06:14:19 +02:00 committed by GitHub
parent 0f90a1b50f
commit e4b0467f9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -600,4 +600,15 @@ headerBar.addEventListener("click", (e) => {
} }
}); });
//------------------------------------------------
// Add a confirmation dialog when leaving the page
// Useful to avoid data loss
//------------------------------------------------
window.addEventListener('beforeunload', function (event) {
// Cancel the event
event.preventDefault();
// Chrome requires returnValue to be set
event.returnValue = '';
});
moveToChatTab(); moveToChatTab();