fix(indicate typos): undefined hints in stop on letter (#5281)

This commit is contained in:
Nad Alaba 2024-04-05 13:19:04 +03:00 committed by GitHub
parent aeaedd209e
commit 2dbd7afa10
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -35,7 +35,8 @@ async function gethtml2canvas(): Promise<typeof import("html2canvas").default> {
function createHintsHtml(
incorrectLtrIndices: number[][],
activeWordLetters: NodeListOf<Element>
activeWordLetters: NodeListOf<Element>,
inputWord: string
): string {
let hintsHtml = "";
for (const adjacentLetters of incorrectLtrIndices) {
@ -43,7 +44,7 @@ function createHintsHtml(
const blockLeft = (activeWordLetters[indx] as HTMLElement).offsetLeft;
const blockWidth = (activeWordLetters[indx] as HTMLElement).offsetWidth;
const blockIndices = `[${indx}]`;
const blockChars = TestInput.input.current[indx];
const blockChars = inputWord[indx];
hintsHtml +=
`<hint data-length=1 data-chars-index=${blockIndices}` +
@ -886,7 +887,7 @@ export async function updateWordElement(
if (hintIndices?.length) {
const activeWordLetters = wordAtIndex.querySelectorAll("letter");
const hintsHtml = createHintsHtml(hintIndices, activeWordLetters);
const hintsHtml = createHintsHtml(hintIndices, activeWordLetters, input);
wordAtIndex.insertAdjacentHTML("beforeend", hintsHtml);
const hintElements = wordAtIndex.getElementsByTagName("hint");
await joinOverlappingHints(hintIndices, activeWordLetters, hintElements);