fix: search-dialog was not autofocusing the text field

Massimo Melina committed Mar 8, 2026 at 22:11 UTC f515674cf375c6861bf6553e7f3343f39ced904d
2 files changed +2 -3
frontend/src/login.ts
+1 -3
@@ -73,9 +73,6 @@ export async function loginDialog(closable=true, reloadAfter=true) {
73 const pwdRef = useRef<HTMLInputElement>()
74 const ipRef = useRef<HTMLInputElement>()
75 const [showPassword, setShowPassword] = useState(false)
76 - useEffect(() => {
77 - setTimeout(() => usrRef.current?.focus()) // setTimeout workarounds problem due to double-mount while in dev
78 - }, [])
76 const {t} = useI18N() // this dialog can be displayed before anything else, accessing protected folder, and needs to be rendered after languages loading
77 return h('form', {
78 onSubmit(ev:any) {
@@ -91,6 +88,7 @@ export async function loginDialog(closable=true, reloadAfter=true) {
88 id: 'login_username',
89 name: 'username',
90 autoComplete: 'username',
91 + autoFocus: true,
92 required: true,
93 onKeyDown
94 }),
shared/dialogs.ts
+1
@@ -131,6 +131,7 @@ function Dialog(d: DialogOptions) {
131 const el = ref.current?.querySelector('.dialog') as HTMLElement | undefined
132 if (!el) return
133 tabCycle(el) // focus first thing inside dialog. This makes JAWS behave
134 + ;(el.querySelector('[autofocus]') as HTMLElement)?.focus() // if any
135 if (!d.position) return
136 // not the nicest of solutions, but short, effective, and used only by short-lived context menus
137 let y = 0