GUACAMOLE-352: Additionally click() while attempting to refocus the input sink field. Do not rely on autofocus, which may result in the field being partly focused (outlined as focused) but not receiving any actual text input.
Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/9f6b2fad Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/9f6b2fad Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/9f6b2fad Branch: refs/heads/master Commit: 9f6b2fad37aa8f087d1464523c4ff1ee75ef861f Parents: e5e01be Author: Michael Jumper <mjum...@apache.org> Authored: Mon Dec 18 14:56:39 2017 -0800 Committer: Michael Jumper <mjum...@apache.org> Committed: Tue Jan 16 10:20:42 2018 -0800 ---------------------------------------------------------------------- .../src/main/webapp/modules/Keyboard.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/9f6b2fad/guacamole-common-js/src/main/webapp/modules/Keyboard.js ---------------------------------------------------------------------- diff --git a/guacamole-common-js/src/main/webapp/modules/Keyboard.js b/guacamole-common-js/src/main/webapp/modules/Keyboard.js index 3a114db..b0930c2 100644 --- a/guacamole-common-js/src/main/webapp/modules/Keyboard.js +++ b/guacamole-common-js/src/main/webapp/modules/Keyboard.js @@ -1440,8 +1440,8 @@ Guacamole.Keyboard.InputSink = function InputSink() { * @type {Element} */ var field = document.createElement('textarea'); - field.setAttribute('autofocus', 'autofocus'); field.style.position = 'fixed'; + field.style.outline = 'none'; field.style.border = 'none'; field.style.width = '10px'; field.style.height = '10px'; @@ -1463,6 +1463,16 @@ Guacamole.Keyboard.InputSink = function InputSink() { // Keep internal field contents clear field.addEventListener("change", clear, false); + // Whenever focus is gained, automatically click to ensure cursor is + // actually placed within the field (the field may simply be highlighted or + // outlined otherwise) + field.addEventListener("focus", function focusReceived() { + window.setTimeout(function deferRefocus() { + field.click(); + field.select(); + }, 0); + }, true); + /** * Attempts to focus the underlying input field. The focus attempt occurs * asynchronously, and may silently fail depending on browser restrictions. @@ -1470,7 +1480,6 @@ Guacamole.Keyboard.InputSink = function InputSink() { this.focus = function focus() { window.setTimeout(function deferRefocus() { field.focus(); // Focus must be deferred to work reliably across browsers - field.select(); }, 0); };