guacamole-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmuehl...@apache.org
Subject [06/32] incubator-guacamole-client git commit: GUACAMOLE-55: Restore focus state after attempting to read local clipboard.
Date Thu, 30 Jun 2016 05:37:00 GMT
GUACAMOLE-55: Restore focus state after attempting to read local clipboard.


Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/01eddd27
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/01eddd27
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/01eddd27

Branch: refs/heads/master
Commit: 01eddd2772d0285025bf448dc279a3bacc5651ff
Parents: 0c6383a
Author: Michael Jumper <mjumper@apache.org>
Authored: Wed Jun 22 01:09:24 2016 -0700
Committer: Michael Jumper <mjumper@apache.org>
Committed: Sun Jun 26 20:44:56 2016 -0700

----------------------------------------------------------------------
 .../webapp/app/client/services/clipboardService.js    | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/01eddd27/guacamole/src/main/webapp/app/client/services/clipboardService.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/client/services/clipboardService.js b/guacamole/src/main/webapp/app/client/services/clipboardService.js
index ed518a1..a81dd0e 100644
--- a/guacamole/src/main/webapp/app/client/services/clipboardService.js
+++ b/guacamole/src/main/webapp/app/client/services/clipboardService.js
@@ -69,6 +69,9 @@ angular.module('client').factory('clipboardService', ['$injector',
 
         var deferred = $q.defer();
 
+        // Track the originally-focused element prior to changing focus
+        var originalElement = document.activeElement;
+
         // Copy the given value into the clipboard DOM element
         clipboardContent.value = text;
         clipboardContent.select();
@@ -79,8 +82,10 @@ angular.module('client').factory('clipboardService', ['$injector',
         else
             deferred.reject();
 
-        // Unfocus the clipboard DOM event to avoid mobile keyboard opening
+        // Unfocus the clipboard DOM event to avoid mobile keyboard opening,
+        // restoring whichever element was originally focused
         clipboardContent.blur();
+        originalElement.focus();
 
         return deferred.promise;
     };
@@ -101,6 +106,9 @@ angular.module('client').factory('clipboardService', ['$injector',
         // clipboard data (in case the copy/cut has not yet completed)
         window.setTimeout(function deferredClipboardRead() {
 
+            // Track the originally-focused element prior to changing focus
+            var originalElement = document.activeElement;
+
             // Clear and select the clipboard DOM element
             clipboardContent.value = '';
             clipboardContent.focus();
@@ -112,8 +120,10 @@ angular.module('client').factory('clipboardService', ['$injector',
             else
                 deferred.reject();
 
-            // Unfocus the clipboard DOM event to avoid mobile keyboard opening
+            // Unfocus the clipboard DOM event to avoid mobile keyboard opening,
+            // restoring whichever element was originally focused
             clipboardContent.blur();
+            originalElement.focus();
 
         }, 100);
 


Mime
View raw message