-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
autofocus HTML attribute not working with curly braces JavaScript expression #4995
Comments
@opensas can confirm this looks like a bug, but you should also be aware that Svelte is very accessibility focused, and autofocus is an accessibility no-no. |
Thanks for the reply @antony , I'm aware of svelte accessibility focused (see what I did?) attitude. What would be the best way to handle autofocus in a a11y friendly way? The way I see it, programatics option to achieve autofocus (element.focus()) will probable have the same problem. |
At some point in the past, Svelte used to handle |
I seem to be wrong about that. A static |
Excuse my ignorance, but I'm inspecting it in the repl I posted and in all cases I see the following html being generated: <body>input to focus: <input autofocus=""><br></body> It's the same wether I execute:
or
In the first case it works, but in the second it won't. I don't quite get how running |
Programmatically creating an element and giving it the |
Absolutely clear I had a look at the genarated js and it's even more clear what's happening: https://svelte.dev/repl/dba0f324a0a14bdfb0df7d1f7af4a2e6?version=3.23.1
so efectively the input.focus() is missing when using js expressions |
I didn't even know this attribute existed. If anyone sees this and needs a quick fix:
Actions for the win |
This is fixed now in 3.40.2 - https://svelte.dev/repl/c11942342a554a0e8df4b28d4248e313?version=3.40.2 |
Describe the bug
The
autofocus
HTML attribute is not working with curly braces JavaScript expressionLogs
Please include browser console and server logs around the time this bug occurred.
To Reproduce
Check this repl and this other repl with a simpler example.
Steps to reproduce:
Create the following svelte component
Expected behavior
The autofocus attribute to work as expected
Severity
annoying, there are workarounds to deal with autofoccus programmatically
The text was updated successfully, but these errors were encountered: