diff --git a/evap/static/ts/src/base-template.ts b/evap/static/ts/src/base-template.ts index 2f3649cf1c3449f9e056d4f2e82b43125f80c2c1..bc5747190b902949f242aed2a2a11e134a672dd5 100644 --- a/evap/static/ts/src/base-template.ts +++ b/evap/static/ts/src/base-template.ts @@ -1,7 +1,7 @@ // This file contains all typescript code for the base.html template. // Fix autofocus on bootstrap modals -> Focus the first element with `autofocus` attribute -document.addEventListener("shown.bs.modal", (e) => { +document.addEventListener("shown.bs.modal", e => { if (!e.target) return; const modalEl = e.target as HTMLElement; const autofocusEl = modalEl.querySelector("[autofocus]") as HTMLElement; diff --git a/evap/static/ts/src/student-vote.ts b/evap/static/ts/src/student-vote.ts index f995fec8036e38e0704de7ec4b69b2265850c313..a8bd32ba1c0889a133d8cc5d07b51aacbb389581 100644 --- a/evap/static/ts/src/student-vote.ts +++ b/evap/static/ts/src/student-vote.ts @@ -1,6 +1,7 @@ function isInvisible(el: Element): boolean { - if (getComputedStyle(el).display === "none") + if (getComputedStyle(el).display === "none") { return true; + } return el.parentElement !== null && isInvisible(el.parentElement); } @@ -22,7 +23,7 @@ function selectByNumberKey(row: HTMLElement, num: number) { const studentForm = document.getElementById("student-vote-form") as HTMLElement; const selectables: NodeListOf<HTMLElement> = studentForm.querySelectorAll(".tab-selectable"); const rows = Array.from(studentForm.getElementsByClassName("tab-row")) as Array<HTMLElement>; -const letterRegex = new RegExp("^[A-Za-zÄÖÜäöü\.\*\+\-]$"); +const letterRegex = new RegExp("^[A-Za-zÄÖÜäöü.*+-]$"); // Sometimes we just want the browser to do it's thing. let disableFocusHandler = false; @@ -90,15 +91,17 @@ studentForm.addEventListener("keydown", (e: KeyboardEvent) => { if (e.key !== "Tab") { if (current.tagName !== "TEXTAREA" && letterRegex.test(e.key)) { const wholeRow = currentRow.closest("div.row"); - if (wholeRow === null) + if (wholeRow === null) { return; + } e.preventDefault(); - const textAnswerButton: HTMLElement | null = wholeRow.querySelector("[data-bs-toggle=\"collapse\"]"); + const textAnswerButton: HTMLElement | null = wholeRow.querySelector('[data-bs-toggle="collapse"]'); const textField: HTMLTextAreaElement | null = wholeRow.querySelector("textarea.tab-selectable"); if (textAnswerButton !== null && textField !== null) { - if (isInvisible(textField)) + if (isInvisible(textField)) { textAnswerButton.click(); + } fancyFocus(textField); textField.value += e.key; textField.dispatchEvent(new Event("input"));