mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-08 06:01:22 +00:00
GUACAMOLE-55: Restore focus state after attempting to read local clipboard.
This commit is contained in:
@@ -69,6 +69,9 @@ angular.module('client').factory('clipboardService', ['$injector',
|
|||||||
|
|
||||||
var deferred = $q.defer();
|
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
|
// Copy the given value into the clipboard DOM element
|
||||||
clipboardContent.value = text;
|
clipboardContent.value = text;
|
||||||
clipboardContent.select();
|
clipboardContent.select();
|
||||||
@@ -79,8 +82,10 @@ angular.module('client').factory('clipboardService', ['$injector',
|
|||||||
else
|
else
|
||||||
deferred.reject();
|
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();
|
clipboardContent.blur();
|
||||||
|
originalElement.focus();
|
||||||
|
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
@@ -101,6 +106,9 @@ angular.module('client').factory('clipboardService', ['$injector',
|
|||||||
// clipboard data (in case the copy/cut has not yet completed)
|
// clipboard data (in case the copy/cut has not yet completed)
|
||||||
window.setTimeout(function deferredClipboardRead() {
|
window.setTimeout(function deferredClipboardRead() {
|
||||||
|
|
||||||
|
// Track the originally-focused element prior to changing focus
|
||||||
|
var originalElement = document.activeElement;
|
||||||
|
|
||||||
// Clear and select the clipboard DOM element
|
// Clear and select the clipboard DOM element
|
||||||
clipboardContent.value = '';
|
clipboardContent.value = '';
|
||||||
clipboardContent.focus();
|
clipboardContent.focus();
|
||||||
@@ -112,8 +120,10 @@ angular.module('client').factory('clipboardService', ['$injector',
|
|||||||
else
|
else
|
||||||
deferred.reject();
|
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();
|
clipboardContent.blur();
|
||||||
|
originalElement.focus();
|
||||||
|
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user