Merge pull request #961 from hgiesel/editorfocus

Fix focus on first field upon opening editor
This commit is contained in:
Damien Elmes 2021-01-31 09:21:11 +10:00 committed by GitHub
commit f1ffc11fb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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