Skip to content

Commit 6588862

Browse files
committed
docs: document <dialog> and falsy-value exceptions
1 parent 8ec2054 commit 6588862

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

docs/rules/template-no-autofocus-attribute.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,28 @@ Examples of **correct** code for this rule:
4040
</template>
4141
```
4242

43+
Explicit opt-out via a falsy value is allowed (parity with
44+
[`jsx-a11y/no-autofocus`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/docs/rules/no-autofocus.md)):
45+
46+
```gjs
47+
<template>
48+
<input autofocus="false" />
49+
<input autofocus={{false}} />
50+
</template>
51+
```
52+
53+
`<dialog>` and its descendants are exempt. A dialog is expected to focus its
54+
initial element on open, per
55+
[MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog):
56+
57+
```gjs
58+
<template>
59+
<dialog>
60+
<button autofocus>Close</button>
61+
</dialog>
62+
</template>
63+
```
64+
4365
## When Not To Use It
4466

4567
If you need to autofocus for specific accessibility or UX requirements and have thoroughly tested with assistive technologies, you may disable this rule for those specific cases.

0 commit comments

Comments
 (0)