From 08ba2f271837f6d74ac0453ac1c6f0424a87652e Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Tue, 14 Jan 2025 10:12:39 +0700 Subject: [PATCH] workaround autofocus bug in svelte-ux --- .../src/lib/entry-editor/inputs/CrdtTextField.svelte | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/frontend/viewer/src/lib/entry-editor/inputs/CrdtTextField.svelte b/frontend/viewer/src/lib/entry-editor/inputs/CrdtTextField.svelte index 04a524612..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} - autofocus={autofocus} class="ws-field gap-2 text-right" classes={{ root: `${editorValue ? '' : 'empty'} ${readonly ? 'readonly' : ''}`, input: 'field-input', container: 'field-container' }} {label}