fix: restore dialog focus using programmatic focus instead of autofocus

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
centdix
2026-02-22 13:51:19 +00:00
co-authored by Claude Opus 4.6
parent 62fea97547
commit aedf012c84
2 changed files with 6 additions and 0 deletions
@@ -10,9 +10,11 @@
} = $props();
let dialogEl: HTMLDialogElement;
let confirmBtn: HTMLButtonElement;
$effect(() => {
dialogEl?.showModal();
confirmBtn?.focus();
});
const btn = "px-3 py-1.5 rounded-md border border-edge bg-surface text-primary text-xs cursor-pointer hover:bg-hover";
@@ -26,6 +28,7 @@
<div class="flex justify-end gap-2">
<button type="button" class={btn} onclick={oncancel} disabled={loading}>Cancel</button>
<button
bind:this={confirmBtn}
type="submit"
class="{btn} !text-white hover:!opacity-90 disabled:!opacity-50 disabled:!cursor-not-allowed flex items-center gap-1.5 {variant === 'accent' ? '!bg-accent !border-accent' : '!bg-danger !border-danger'}"
disabled={loading}
@@ -8,9 +8,11 @@
let sshHost = $state(localStorage.getItem(STORAGE_KEY) ?? "");
let dialogEl: HTMLDialogElement;
let inputEl: HTMLInputElement;
$effect(() => {
dialogEl?.showModal();
inputEl?.focus();
});
function handleSave() {
@@ -34,6 +36,7 @@
SSH Host <span class="opacity-60">(for "Open in Cursor")</span>
</label>
<input
bind:this={inputEl}
id="ssh-host"
type="text"
class="w-full px-2.5 py-1.5 rounded-md border border-edge bg-surface text-primary text-[13px] placeholder:text-muted/50 outline-none focus:border-accent"