necouchman commented on a change in pull request #592:
URL: https://github.com/apache/guacamole-client/pull/592#discussion_r585871711



##########
File path: guacamole/src/main/webapp/app/client/controllers/clientController.js
##########
@@ -219,6 +220,26 @@ angular.module('client').controller('clientController', 
['$scope', '$routeParams
         remaining: 15
     };
 
+    /**
+     * Catch window or tab closing (ctrl-w) and prompt the user if there is an 
active connection
+     *
+     * @param {Event} e
+     * @returns {undefined}
+     */
+    var windowCloseListener = function onBeforeUnload(e) {
+        var managedClient = $scope.client;
+        if (managedClient) {
+
+            // Get current connection state
+            var connectionState = managedClient.clientState.connectionState;
+
+            // If connected, prompt to close
+            if (connectionState === 
ManagedClientState.ConnectionState.CONNECTED)
+                e.preventDefault();
+                e.returnValue = '';

Review comment:
       It's possible I'm just missing something here about how JS behaves, but 
does this actually prompt the user? It looks like all it does is check if the 
connection is active, block the default action, and clear the return value of 
the event? Does that somehow generate a browser prompt? Or does this just 
silently block the attempt to close the window?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to