Skip to content

Commit

Permalink
Autofocus lexeme form when new entry dialog opens
Browse files Browse the repository at this point in the history
  • Loading branch information
rmunn committed Jan 10, 2025
1 parent bf552c7 commit 228ea09
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, boolean> = {};
let currentView = useCurrentView();
Expand All @@ -31,11 +32,12 @@
<div class="multi-field field" class:collapse-field={collapse} class:empty class:hidden={!$currentView.fields[id].show} style:grid-area={id}>
<FieldTitle {id} {name} />
<div class="fields">
{#each writingSystems as ws (ws.wsId)}
{#each writingSystems as ws, idx (ws.wsId)}
<CrdtTextField
on:change={() => 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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
export let labelPlacement: ComponentProps<TextField>['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
Expand All @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
<MultiFieldEditor on:change={() => dispatch('change', {entry})}
bind:value={entry.lexemeForm}
{readonly}
autofocus={modalMode}
id="lexemeForm"
wsType="vernacular"/>

Expand Down

0 comments on commit 228ea09

Please sign in to comment.