From d3a28f6ce3d73412c9ccdb2675aaeac2ec43b49b Mon Sep 17 00:00:00 2001 From: Miodec Date: Wed, 17 Mar 2021 17:58:04 +0000 Subject: [PATCH] fixed a bug where using keymap next with zen mode would freeze the website --- src/js/script.js | 24 ++++++++++++------------ src/js/test/keymap.js | 1 + 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/js/script.js b/src/js/script.js index 5323c7357..690aefbf6 100644 --- a/src/js/script.js +++ b/src/js/script.js @@ -750,15 +750,15 @@ function showWords() { if (Config.mode === "zen") { $(document.querySelector(".word")).remove(); - } - - if (Config.keymapMode === "next") { - Keymap.highlightKey( - wordsList[currentWordIndex] - .substring(currentInput.length, currentInput.length + 1) - .toString() - .toUpperCase() - ); + } else { + if (Config.keymapMode === "next") { + Keymap.highlightKey( + wordsList[currentWordIndex] + .substring(currentInput.length, currentInput.length + 1) + .toString() + .toUpperCase() + ); + } } TestUI.updateActiveElement(); @@ -4137,7 +4137,7 @@ function handleBackspace(event) { Sound.playClick(Config.playSoundOnClick); if (Config.keymapMode === "react") { Keymap.flashKey(event.code, true); - } else if (Config.keymapMode === "next") { + } else if (Config.keymapMode === "next" && Config.mode !== "zen") { Keymap.highlightKey( wordsList[currentWordIndex] .substring(currentInput.length, currentInput.length + 1) @@ -4307,7 +4307,7 @@ function handleSpace(event, isEnter) { if (Config.keymapMode === "react") { Keymap.flashKey(event.code, true); - } else if (Config.keymapMode === "next") { + } else if (Config.keymapMode === "next" && Config.mode !== "zen") { Keymap.highlightKey( wordsList[currentWordIndex] .substring(currentInput.length, currentInput.length + 1) @@ -4600,7 +4600,7 @@ function handleAlpha(event) { //keymap if (Config.keymapMode === "react") { Keymap.flashKey(event.key, thisCharCorrect); - } else if (Config.keymapMode === "next") { + } else if (Config.keymapMode === "next" && Config.mode !== "zen") { Keymap.highlightKey( wordsList[currentWordIndex] .substring(currentInput.length, currentInput.length + 1) diff --git a/src/js/test/keymap.js b/src/js/test/keymap.js index 9a43b6776..f65184edd 100644 --- a/src/js/test/keymap.js +++ b/src/js/test/keymap.js @@ -4,6 +4,7 @@ import layouts from "./layouts"; //TODO remove after wordslist and currentinput and current word index are in a module export function highlightKey(currentKey) { + if (Config.keymapMode === "next") return; try { if ($(".active-key") != undefined) { $(".active-key").removeClass("active-key");