diff --git a/package.json b/package.json index 1eeb64f..d023de2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fwdekker/template", - "version": "3.2.0", + "version": "3.2.1", "description": "The base template for pages on fwdekker.com.", "author": "Florine W. Dekker", "license": "MIT", diff --git a/src/main/js/Validation.ts b/src/main/js/Validation.ts index 084837f..f5790eb 100644 --- a/src/main/js/Validation.ts +++ b/src/main/js/Validation.ts @@ -123,13 +123,14 @@ export function clearInputValidity(input: HTMLInputElement): void { * * @param input the input to show as invalid * @param message the message explaining what is invalid + * @param focus `true` if `input` should receive focus */ -export function showInputInvalid(input: HTMLInputElement, message?: string): void { +export function showInputInvalid(input: HTMLInputElement, message?: string, focus: boolean = true): void { clearInputValidity(input); input.classList.add("invalid"); input.setAttribute("aria-invalid", "true"); - input.focus(); + if (focus) input.focus(); const label = $(`label[for="${input.id}"]`) ?? $(`*[data-label-for="${input.id}"]`); if (label != null)