diff --git a/frontend/viewer/src/lib/entry-editor/field-editors/MultiFieldEditor.svelte b/frontend/viewer/src/lib/entry-editor/field-editors/MultiFieldEditor.svelte index 6d729adb6..55e509b22 100644 --- a/frontend/viewer/src/lib/entry-editor/field-editors/MultiFieldEditor.svelte +++ b/frontend/viewer/src/lib/entry-editor/field-editors/MultiFieldEditor.svelte @@ -19,6 +19,7 @@ export let wsType: WritingSystemSelection; export let value: IMultiString; export let readonly: boolean = false; + export let autofocus: boolean = false; let unsavedChanges: Record = {}; let currentView = useCurrentView(); @@ -31,11 +32,12 @@
- {#each writingSystems as ws (ws.wsId)} + {#each writingSystems as ws, idx (ws.wsId)} dispatch('change', { value })} bind:value={value[ws.wsId]} bind:unsavedChanges={unsavedChanges[ws.wsId]} + autofocus={autofocus && (idx == 0)} label={collapse ? undefined : ws.abbreviation} labelPlacement={collapse ? undefined : 'left'} placeholder={collapse ? ws.abbreviation : undefined} diff --git a/frontend/viewer/src/lib/entry-editor/inputs/CrdtTextField.svelte b/frontend/viewer/src/lib/entry-editor/inputs/CrdtTextField.svelte index 0bd5798c1..657c1dca2 100644 --- a/frontend/viewer/src/lib/entry-editor/inputs/CrdtTextField.svelte +++ b/frontend/viewer/src/lib/entry-editor/inputs/CrdtTextField.svelte @@ -1,7 +1,7 @@ - onEditorValueChange(e.detail.inputValue)} on:blur={(e) => {if (e.target) save()}} - actions={(el) => { addTitleToLabel(el); return []; }} + actions={(el) => { + addTitleToLabel(el); + // autofocus requires a delay otherwise it won't work in a dialog + // also we can't use the autofocus attribute because of https://github.com/techniq/svelte-ux/issues/532 + return autofocus ? [autoFocusFunc(el, {delay: 5})] : []; + }} value={editorValue} disabled={readonly} class="ws-field gap-2 text-right" diff --git a/frontend/viewer/src/lib/entry-editor/object-editors/EntryEditor.svelte b/frontend/viewer/src/lib/entry-editor/object-editors/EntryEditor.svelte index 531ba11b9..84fee67b4 100644 --- a/frontend/viewer/src/lib/entry-editor/object-editors/EntryEditor.svelte +++ b/frontend/viewer/src/lib/entry-editor/object-editors/EntryEditor.svelte @@ -116,6 +116,7 @@ dispatch('change', {entry})} bind:value={entry.lexemeForm} {readonly} + autofocus={modalMode} id="lexemeForm" wsType="vernacular"/>