diff --git a/src/views/FormBuilder.svelte b/src/views/FormBuilder.svelte index 480f91e2..d9d8665b 100644 --- a/src/views/FormBuilder.svelte +++ b/src/views/FormBuilder.svelte @@ -26,6 +26,7 @@ $: isValid = isValidFormDefinition(definition); $: errors = validateFields(definition.fields); + $: activeFieldIndex = 0; function folderField(element: HTMLElement, index: number) { const field = definition.fields[index]; @@ -45,6 +46,18 @@ }); } + function scrollWhenActive(element: HTMLElement, index: number) { + function update() { + if (index === activeFieldIndex) { + element.scrollIntoView({ behavior: "smooth", block: "center" }); + } + } + update(); + return { + update, + }; + } + function findFreeName(fieldIndex: number): string { const field = definition.fields[fieldIndex]; let name = field.name; @@ -130,7 +143,8 @@ input: { type: "text" }, }, ]; - onChange(); + // onChange(); + activeFieldIndex = definition.fields.length - 1; }}>Add more fields