GUACAMOLE-1292: Merge prompt user to confirm closing guacamole if at least one client is active.

This commit is contained in:
Virtually Nick authored and GitHub committed 2025-11-04 12:57:17 -06:00
commit 07bbc36d6f
1 file changed
+19
@@ -320,8 +320,27 @@ angular.module('client').factory('guacClientManager', ['$injector',
};
/**
* Handles the beforeunload event. If any managed clients are active, the
* user is prompted to confirm leaving the page.
*
* @param {event} e
* The beforeunload event.
*/
service.beforeUnload = function beforeUnload(e) {
const managedClients = storedManagedClients();
if (Object.keys(managedClients).length > 0) {
e.preventDefault();
// For older browsers
e.returnValue = true;
}
};
// Disconnect all clients when window is unloaded
$window.addEventListener('unload', service.clear);
$window.addEventListener('beforeunload', service.beforeUnload);
return service;