term: do not re-focus on keyup when on mobile

Doing this will mess up the mobile browsers.
Although we still don't support mobile browsers very well, this can at least make it usable on them.
This commit is contained in:
Peter Cai
2018-06-03 12:16:49 +08:00
parent 34b6287e0c
commit 5b9cc257a8
3 changed files with 20 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
(function() {
var $, State, Terminal, cancel, cols, openTs, quit, rows, s, ws,
var $, State, Terminal, cancel, cols, isMobile, openTs, quit, rows, s, ws,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
cols = rows = null;
@@ -131,6 +131,10 @@
return false;
};
isMobile = function() {
return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
};
s = 0;
State = {
@@ -201,11 +205,13 @@
this.inputHelper.addEventListener('keypress', this.keyPress.bind(this));
addEventListener('keydown', this.keyDown.bind(this));
addEventListener('keypress', this.keyPress.bind(this));
addEventListener('keyup', (function(_this) {
return function() {
return _this.inputHelper.focus();
};
})(this));
if (!isMobile()) {
addEventListener('keyup', (function(_this) {
return function() {
return _this.inputHelper.focus();
};
})(this));
}
addEventListener('focus', this.focus.bind(this));
addEventListener('blur', this.blur.bind(this));
addEventListener('resize', (function(_this) {

File diff suppressed because one or more lines are too long

View File

@@ -34,6 +34,9 @@ cancel = (ev) ->
ev.cancelBubble = true
false
isMobile = ->
/iPhone|iPad|iPod|Android/i.test navigator.userAgent
s = 0
State =
normal: s++
@@ -123,7 +126,9 @@ class Terminal
addEventListener 'keydown', @keyDown.bind(@)
addEventListener 'keypress', @keyPress.bind(@)
# Always focus on the inputHelper textarea
addEventListener 'keyup', => @inputHelper.focus()
# Don't do this on mobile, it will mess up the IME
unless isMobile()
addEventListener 'keyup', => @inputHelper.focus()
addEventListener 'focus', @focus.bind(@)
addEventListener 'blur', @blur.bind(@)
addEventListener 'resize', => @resize()