mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Fix focus on first field upon opening editor
This commit is contained in:
parent
b66bedbc9f
commit
126af1fef3
1 changed files with 7 additions and 2 deletions
|
@ -280,10 +280,10 @@ function onFocus(evt: FocusEvent): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
function focusField(n: number): void {
|
function focusField(n: number): void {
|
||||||
const field = document.getElementById(`f${n}`) as EditingArea;
|
const field = getEditorField(n);
|
||||||
|
|
||||||
if (field) {
|
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>(
|
function forEditorField<T>(
|
||||||
values: T[],
|
values: T[],
|
||||||
func: (field: EditorField, value: T) => void
|
func: (field: EditorField, value: T) => void
|
||||||
|
|
Loading…
Reference in a new issue