From 228ea099acdeebbdc8327ea28695d01d76b7c133 Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Fri, 10 Jan 2025 16:11:26 -0500 Subject: [PATCH] Autofocus lexeme form when new entry dialog opens --- .../lib/entry-editor/field-editors/MultiFieldEditor.svelte | 4 +++- .../viewer/src/lib/entry-editor/inputs/CrdtTextField.svelte | 2 ++ .../src/lib/entry-editor/object-editors/EntryEditor.svelte | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) 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..04a524612 100644 --- a/frontend/viewer/src/lib/entry-editor/inputs/CrdtTextField.svelte +++ b/frontend/viewer/src/lib/entry-editor/inputs/CrdtTextField.svelte @@ -9,6 +9,7 @@ export let labelPlacement: ComponentProps['labelPlacement'] = undefined; export let placeholder: string | undefined = undefined; export let readonly: boolean | undefined = undefined; + export let autofocus: boolean = false; let append: HTMLElement; // Labels don't always fit (beause WS's can be long and ugly), so a title might be important sometimes @@ -25,6 +26,7 @@ actions={(el) => { addTitleToLabel(el); return []; }} value={editorValue} disabled={readonly} + autofocus={autofocus} class="ws-field gap-2 text-right" classes={{ root: `${editorValue ? '' : 'empty'} ${readonly ? 'readonly' : ''}`, input: 'field-input', container: 'field-container' }} {label} 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 00837a772..149f6215a 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"/>