refactor: replace jquery event with vanilla event

This commit is contained in:
Miodec 2024-02-22 17:52:59 +01:00
parent 7e73d47f09
commit b03ea666c8

View file

@ -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") {