From b03ea666c8530b90d44c3126cce8a30fae58fad2 Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 22 Feb 2024 17:52:59 +0100 Subject: [PATCH] refactor: replace jquery event with vanilla event --- frontend/src/ts/controllers/input-controller.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/ts/controllers/input-controller.ts b/frontend/src/ts/controllers/input-controller.ts index 911a8c84e..066d6a05a 100644 --- a/frontend/src/ts/controllers/input-controller.ts +++ b/frontend/src/ts/controllers/input-controller.ts @@ -744,14 +744,18 @@ function handleChar( handleSpace(); } + const currentWord = TestWords.words.getCurrent(); + const doesCurrentWordHaveTab = /^\t+/.test(TestWords.words.getCurrent()); + const isCurrentCharTab = currentWord[TestInput.input.current.length] === "\t"; + if ( thisCharCorrect && Config.language.startsWith("code") && - /^\t+/.test(TestWords.words.getCurrent()) && - TestWords.words.getCurrent()[TestInput.input.current.length] === "\t" + doesCurrentWordHaveTab && + isCurrentCharTab ) { - // handleChar("\t", TestInput.input.current.length); - $("#wordsInput").trigger($.Event("keydown", { key: "Tab", code: "Tab" })); + const tabEvent = new KeyboardEvent("keydown", { key: "Tab", code: "Tab" }); + document.dispatchEvent(tabEvent); } if (char !== "\n") {