GUACAMOLE-352: Track in-progress composition, ignoring "input" events for a composition which is known to be incomplete.

This commit is contained in:
Michael Jumper
2017-12-17 21:51:19 -08:00
parent fd47d1d7ef
commit 646f9732f3

View File

@@ -1231,6 +1231,15 @@ Guacamole.Keyboard = function(element) {
};
/**
* The in-progress composition, if any, such as the intermediate result of
* pressing a series of dead keys.
*
* @private
* @type {String}
*/
var inProgressComposition = '';
/**
* Handles the given "input" event, typing the data within the input text.
* If the event is complete (text is provided), handling of "compositionend"
@@ -1245,6 +1254,11 @@ Guacamole.Keyboard = function(element) {
// Only intercept if handler set
if (!guac_keyboard.onkeydown && !guac_keyboard.onkeyup) return;
// Ignore input events which represent the in-progress composition,
// as reported by composition events
if (e.data === inProgressComposition)
return;
// Type all content written
if (e.data && isComposed(e.data)) {
element.removeEventListener("compositionend", handleComposition, false);
@@ -1280,6 +1294,14 @@ Guacamole.Keyboard = function(element) {
element.addEventListener("input", handleInput, false);
element.addEventListener("compositionend", handleComposition, false);
element.addEventListener("compositionstart", function resetComposition() {
inProgressComposition = '';
}, false);
element.addEventListener("compositionupdate", function updateComposition(e) {
inProgressComposition = e.data;
}, false);
};
/**