web/elements: fix detection of inner forms, catch errors and don't close modal

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-03-25 22:08:09 +01:00
parent 72cca0473a
commit 2e58982419
1 changed files with 4 additions and 2 deletions

View File

@ -7,13 +7,15 @@ import { Form } from "./Form";
export class ModalForm extends ModalButton { export class ModalForm extends ModalButton {
confirm(): void { confirm(): void {
this.querySelectorAll<Form<unknown>>("ak-form").forEach(form => { this.querySelectorAll<Form<unknown>>("[slot=form]").forEach(form => {
const formPromise = form.submit(new Event("submit")); const formPromise = form.submit(new Event("submit"));
if (!formPromise) { if (!formPromise) {
return; return;
} }
formPromise.then(() => { formPromise.then((a) => {
this.open = false; this.open = false;
}).catch((e) => {
console.log(e);
}); });
}); });
} }