Fixed issues with auto complete not working correctly with form sync

This commit is contained in:
BordedDev 2025-03-08 18:09:14 +01:00
parent 6ecd356cc0
commit 804556b74d
No known key found for this signature in database
GPG Key ID: C5F495EAE56673BF

View File

@ -165,6 +165,9 @@ class GenericField extends HTMLElement {
const me = this;
this.inputElement.addEventListener("keyup", (e) => {
if (e.key === 'Enter') {
const event = new CustomEvent("change", {detail: me, bubbles: true});
me.dispatchEvent(event);
me.dispatchEvent(new Event("submit"));
} else if (me.field.value !== e.target.value) {
const event = new CustomEvent("change", {detail: me, bubbles: true});
@ -177,6 +180,11 @@ class GenericField extends HTMLElement {
me.dispatchEvent(event);
});
this.inputElement.addEventListener("blur", (e) => {
const event = new CustomEvent("change", {detail: me, bubbles: true});
me.dispatchEvent(event);
}, true);
this.container.appendChild(this.inputElement);
}
@ -307,6 +315,16 @@ class GenericForm extends HTMLElement {
}
}
});
fieldElement.addEventListener("submit", async (e) => {
const isValid = await this.validate();
if (isValid) {
const saveResult = await this.submit();
if (saveResult.redirect_url) {
window.location.pathname = saveResult.redirect_url;
}
}
})
});
} catch (error) {