Skip to content

autofocus is not working on input rerender in Chrome and Firefox #15261

@gyzerok

Description

@gyzerok

Describe the bug

If you have an input and then rerender your view with another autofocused input, then autofocus does not seem to work. I see this bug in Chrome and Firefox, but in Safari it seems to work fine.

Reproduction

Just click button multiple times in this REPL.

<script>
	let input = $state(0)
</script>

<button onclick={() => (input++)}>click</button>
{#key input}
	<input type="text" placeholder={input} autofocus />
{/key}

System Info

Firefox 135.0 (20250130195129)
Chrome 133.0.6943.53 (Official Build) (arm64)
Safari 18.3 (20620.2.4.11.5)

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions