From 0891a32aeca33a3b3a5e3cf2243492ebda138416 Mon Sep 17 00:00:00 2001 From: Laurens Weijs Date: Tue, 17 Dec 2024 11:37:15 +0100 Subject: [PATCH] Prevent enter in the edit measure modal --- amt/site/static/ts/amt.ts | 12 ++++++++++++ .../algorithms/details_measure_modal.html.j2 | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/amt/site/static/ts/amt.ts b/amt/site/static/ts/amt.ts index 429ed072..0a2ba86f 100644 --- a/amt/site/static/ts/amt.ts +++ b/amt/site/static/ts/amt.ts @@ -426,3 +426,15 @@ export function getFiles(element: HTMLInputElement, target_id: string) { } } } + +const form = document.getElementById( + "form-edit-measure", +) as HTMLFormElement | null; + +if (form) { + form.addEventListener("keydown", (event: KeyboardEvent) => { + if (event.key === "Enter") { + event.preventDefault(); + } + }); +} diff --git a/amt/site/templates/algorithms/details_measure_modal.html.j2 b/amt/site/templates/algorithms/details_measure_modal.html.j2 index c813fcd2..f50ef367 100644 --- a/amt/site/templates/algorithms/details_measure_modal.html.j2 +++ b/amt/site/templates/algorithms/details_measure_modal.html.j2 @@ -16,7 +16,8 @@ hx-target-error="#errorContainer" hx-swap="innerHTML" method="post" - class="rvo-layout-column rvo-layout-gap--md"> + class="rvo-layout-column rvo-layout-gap--md" + id="form-edit-measure">