diff --git a/client/js/autocompletion.js b/client/js/autocompletion.js index 4eb2cb92..ab86c70a 100644 --- a/client/js/autocompletion.js +++ b/client/js/autocompletion.js @@ -174,19 +174,24 @@ const backgroundColorStrategy = { function enableAutocomplete(inputRef) { enabled = true; + let autocompleting = false; let tabCount = 0; let lastMatch = ""; let currentMatches = []; input = $(inputRef); - input.on("input.tabcomplete", () => { + input.on("input.tabcomplete", (e) => { + if (e.detail === "autocomplete") { + return; + } + tabCount = 0; currentMatches = []; lastMatch = ""; }); Mousetrap(input.get(0)).bind("tab", (e) => { - if (input.data("autocompleting")) { + if (autocompleting) { return; } @@ -218,7 +223,9 @@ function enableAutocomplete(inputRef) { input.val(text.substr(0, position) + newMatch); // Propagate change to Vue model - input.get(0).dispatchEvent(new Event("input")); + input.get(0).dispatchEvent(new CustomEvent("input", { + detail: "autocomplete", + })); lastMatch = newMatch; tabCount++; @@ -250,11 +257,11 @@ function enableAutocomplete(inputRef) { }); textcomplete.on("show", () => { - input.data("autocompleting", true); + autocompleting = true; }); textcomplete.on("hidden", () => { - input.data("autocompleting", false); + autocompleting = false; }); } diff --git a/client/js/socket-events/init.js b/client/js/socket-events/init.js index 7fd5a7a8..1e807700 100644 --- a/client/js/socket-events/init.js +++ b/client/js/socket-events/init.js @@ -13,7 +13,7 @@ const {vueApp} = require("../vue"); socket.on("init", function(data) { $("#loading-page-message, #connection-error").text("Rendering…"); - let previousActive = vueApp.activeChannel && vueApp.activeChannel.channel.id; + const previousActive = vueApp.activeChannel && vueApp.activeChannel.channel.id; const networks = new Set(JSON.parse(storage.get("thelounge.networks.collapsed")));