Fix focus on first field upon opening editor

This commit is contained in:
Henrik Giesel 2021-01-30 14:20:14 +01:00
parent b66bedbc9f
commit 126af1fef3

View file

@ -280,10 +280,10 @@ function onFocus(evt: FocusEvent): void {
}
function focusField(n: number): void {
const field = document.getElementById(`f${n}`) as EditingArea;
const field = getEditorField(n);
if (field) {
field.focusEditable();
field.editingArea.focusEditable();
}
}
@ -606,6 +606,11 @@ function adjustFieldAmount(amount: number): void {
}
}
function getEditorField(n: number): EditorField | null {
const fields = document.getElementById("fields").children;
return (fields[n] as EditorField) ?? null;
}
function forEditorField<T>(
values: T[],
func: (field: EditorField, value: T) => void