Wrong a11y wargning on <dialog> with autofocus attribute

#9225

Development PR

Issue

Solved
S
shadow-identity
Sep 18, 2023, 4:40 PM

Describe the bug

Ally warning "Avoid using autofocus" appears on <dialog autofocus> element definition. But using of autofocus on dialog or its descendants is recommended by the standard: https://html.spec.whatwg.org/multipage/interactive-elements.html#the-dialog-element

As such, authors should use the autofocus attribute on the descendant element of the dialog that the user is expected to immediately interact with after the dialog opens. If there is no such element, then authors should use the autofocus attribute on the dialog element itself.

Reproduction

<dialog autofocus>
	I'm a dialog
</dialog>

https://svelte.dev/repl/483135a2842e4da6ba6f24ea63430cf2?version=4.2.0

Logs

No response

System Info

N/A

Severity

annoyance

👍 8

Info

Closed at Jul 11, 2025, 5:42 PM
Assignees None
Labels a11y
Milestone None