From 7267f89377c0859addf7ee4e27b9e86e8fc5e35c Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Tue, 13 Mar 2018 10:04:59 +0200 Subject: [PATCH] Do not aggressively focus input when clicking anywhere --- client/js/lounge.js | 12 +----------- client/js/utils.js | 8 -------- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/client/js/lounge.js b/client/js/lounge.js index 3f35d757..01048e4b 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -223,16 +223,6 @@ $(function() { input.trigger("focus"); } }; - - $(window).on("focus", focus); - - chat.on("click", ".chat", function() { - setTimeout(function() { - if (window.getSelection().isCollapsed) { - focus(); - } - }, 2); - }); } if (navigator.platform.match(/(Mac|iPhone|iPod|iPad)/i)) { @@ -241,7 +231,7 @@ $(function() { $("#form").on("submit", function(e) { e.preventDefault(); - utils.forceFocus(); + focus(); const target = chat.data("id"); const text = input.val(); diff --git a/client/js/utils.js b/client/js/utils.js index 9e0bc37c..e972425e 100644 --- a/client/js/utils.js +++ b/client/js/utils.js @@ -2,7 +2,6 @@ const $ = require("jquery"); const escape = require("css.escape"); -const input = $("#input"); const viewport = $("#viewport"); var serverHash = -1; // eslint-disable-line no-var @@ -14,7 +13,6 @@ module.exports = { serverHash, lastMessageId, confirmExit, - forceFocus, scrollIntoViewNicely, hasRoleInChannel, move, @@ -54,12 +52,6 @@ function hasRoleInChannel(channel, roles) { return user.parent().is("." + roles.join(", .")); } -// Triggering click event opens the virtual keyboard on mobile -// This can only be called from another interactive event (e.g. button click) -function forceFocus() { - input.trigger("click").trigger("focus"); -} - // Reusable scrollIntoView parameters for channel list / user list function scrollIntoViewNicely(el) { // Ideally this would use behavior: "smooth", but that does not consistently work in e.g. Chrome