Prevent loosing focus after a char composition ended by Tab key. Fix #1341 (#1349)

This commit is contained in:
chabou 2017-01-07 02:46:54 +01:00 committed by Guillermo Rauch
parent 0c71863560
commit 1b6d925524

View file

@ -182,11 +182,22 @@ hterm.Terminal.prototype.copySelectionToClipboard = function () {
}
};
let lastEventTimeStamp;
let lastEventKey;
// passthrough all the commands that are meant to control
// hyper and not the terminal itself
const oldKeyDown = hterm.Keyboard.prototype.onKeyDown_;
hterm.Keyboard.prototype.onKeyDown_ = function (e) {
const modifierKeysConf = this.terminal.modifierKeys;
if (e.timeStamp === lastEventTimeStamp && e.key === lastEventKey) {
// Event was already processed.
// It seems to occur after a char composition ended by Tab and cause a blur.
// See https://github.com/zeit/hyper/issues/1341
e.preventDefault();
return;
}
lastEventTimeStamp = e.timeStamp;
lastEventKey = e.key;
if (e.altKey &&
e.which !== 16 && // Ignore other modifer keys