fix(core): update

This commit is contained in:
2023-04-12 02:47:45 +02:00
parent d6047f2e78
commit f75a3714ae
7 changed files with 56 additions and 20 deletions

View File

@ -54,7 +54,7 @@ export class DeesForm extends DeesElement {
`;
}
public firstUpdated() {
public async firstUpdated() {
const formChildren = this.getFormChildren();
this.checkRequiredStatus();
for (const child of formChildren) {
@ -65,6 +65,7 @@ export class DeesForm extends DeesElement {
this.checkRequiredStatus();
});
}
await this.instrumentBehaviours();
}
public getFormChildren() {
@ -170,4 +171,21 @@ export class DeesForm extends DeesElement {
submitButton.text = textStateArg;
}
public async instrumentBehaviours() {
const children = this.getFormChildren();
for (const child of children) {
child.addEventListener('keydown', (eventArg) => {
if (eventArg.key === 'Enter') {
const currentIndex = children.indexOf(child);
if (currentIndex < children.length - 1) {
children[currentIndex + 1].focus();
} else {
children[currentIndex].blur();
this.getSubmitButton().focus();
}
}
});
}
}
}