-
-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Input element sometimes won't get focus (with Superforms) #1014
Comments
Current workaround: $effect(() => {
if ($errors.amount) {
setTimeout(() => document.querySelector('input[name="amount"]')?.focus());
}
}); |
Can you reproduce this with Svelte 4? I'm not able to. Or does the same thing happen with a regular (non-component) input? You're on the money about usually using a |
True, I cannot reproduce it on Svelte 4 either. But it works with a regular input even on Svelte 5. I could post an issue at the Svelte repo, but maybe a dependency on both Superforms and shadcn-svelte won't be appreciated. :) |
We could just recreate an |
I think I managed to reproduce it without any of the libs, will post an issue at Svelte. |
Nope, it was harder than I thought. |
So you can't reproduce by creating an |
Describe the bug
As you certainly know, Superforms has an autoFocusOnError option, enabled as default, focusing on an error field when the form is submitted. I noticed that the Input component doesn't always get focus.
I've been debugging Superforms, changing the wait time before focusing from the current
await tick()
to setTimeout with 100 ms delay, but nothing seems to work, so I don't think it's a Superforms issue.Reproduction
https://github.com/ciscoheat/shadcn-svelte-not-focusing
Instructions are included there.
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: