interactive-supports-focus
What it does
Section titled “What it does”Reports an element with a click or key handler that cannot take focus: no tabindex, not a control or link with href, and no role that is not a widget (heading, listitem, dialog, …). The role of the element is named in the message. Hidden, presentational and aria-disabled="true" elements are left alone.
Why it matters
Section titled “Why it matters”An element that does something when it is clicked or when a key is pressed must be reachable by the Tab key, or a keyboard user never gets to trigger it. Add tabindex="0" or use a native control such as <button>.
Example
Section titled “Example”<div (click)="a()"></div><div (click)="a()" (keydown.enter)="a()" tabindex="0"></div><div on-click="a()" role="presentation"></div>...<a (click)="a()" routerLink="/x">x</a><a (click)="a()">x</a><app-card (click)="a()"></app-card><div role="heading" (keydown)="a()"></div>@if (ok) { <div (click)="a()" aria-hidden="true"></div> }...Configuration
Section titled “Configuration”angular: lint: rules: interactive-supports-focus: warn # off (default), warn, errorhtml: lint: rules: interactive-supports-focus: warn # off (default), warn, errorsvelte: lint: rules: interactive-supports-focus: warn # off (default), warn, errorvue: lint: rules: interactive-supports-focus: warn # off (default), warn, errorEnabled by the presets: html/angular-eslint-recommended.
Suppress one line with sudsy-disable-next-line interactive-supports-focus in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| angular-eslint | interactive-supports-focus |
full |