Skip to content

Latest commit

 

History

History
47 lines (34 loc) · 2.64 KB

File metadata and controls

47 lines (34 loc) · 2.64 KB

ember/template-require-aria-activedescendant-tabindex

💼 This rule is enabled in the 📋 template-lint-migration config.

🔧 This rule is automatically fixable by the --fix CLI option.

This rule requires non-interactive HTML elements using the aria-activedescendant attribute to declare a tabindex of 0 or -1.

The aria-activedescendant attribute identifies the active descendant element of a composite widget, textbox, group, or application with document focus. This attribute is placed on the container element of the input control, and its value is set to the ID of the active child element. This allows screen readers to communicate information about the currently active element as if it has focus, while actual focus of the DOM remains on the container element.

Elements with aria-activedescendant must be focusable to support keyboard navigation. tabindex="0" puts the element in the natural tab order; tabindex="-1" makes it focusable programmatically (e.g. via roving focus) but skips it in the tab order. Both are valid patterns for composite widgets — see the W3C APG — Managing focus in composites using aria-activedescendant.

Examples

This rule forbids the following:

<template>
  <div aria-activedescendant='some-id'></div>
  <div aria-activedescendant='some-id' tabindex='-2'></div>
  <input aria-activedescendant={{some-id}} tabindex='-100' />
</template>

This rule allows the following:

<template>
  <CustomComponent />
  <CustomComponent aria-activedescendant={{some-id}} />
  <CustomComponent aria-activedescendant={{some-id}} tabindex={{0}} />
  <div aria-activedescendant='some-id' tabindex='0'></div>
  <div aria-activedescendant='some-id' tabindex='-1'></div>
  <input />
  <input aria-activedescendant={{some-id}} />
  <input aria-activedescendant={{some-id}} tabindex={{0}} />
  <input aria-activedescendant={{some-id}} tabindex={{-1}} />
</template>

References