選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

aria-activedescendant-has-tabindex.md 1.8 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # aria-activedescendant-has-tabindex
  2. `aria-activedescendant` is used to manage focus within a [composite widget](https://www.w3.org/TR/wai-aria/roles#composite_header).
  3. The element with the attribute `aria-activedescendant` retains the active document
  4. focus; it indicates which of its child elements has secondary focus by assigning
  5. the ID of that element to the value of `aria-activedescendant`. This pattern is
  6. used to build a widget like a search typeahead select list. The search input box
  7. retains document focus so that the user can type in the input. If the down arrow
  8. key is pressed and a search suggestion is highlighted, the ID of the suggestion
  9. element will be applied as the value of `aria-activedescendant` on the input
  10. element.
  11. Because an element with `aria-activedescendant` must be tabbable, it must either
  12. have an inherent `tabIndex` of zero or declare a `tabIndex` of zero with the `tabIndex`
  13. attribute.
  14. #### References
  15. 1. [MDN](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-activedescendant_attribute)
  16. ## Rule details
  17. This rule takes no arguments.
  18. ### Succeed
  19. ```jsx
  20. <CustomComponent />
  21. <CustomComponent aria-activedescendant={someID} />
  22. <CustomComponent aria-activedescendant={someID} tabIndex={0} />
  23. <CustomComponent aria-activedescendant={someID} tabIndex={-1} />
  24. <div />
  25. <input />
  26. <div tabIndex={0} />
  27. <div aria-activedescendant={someID} tabIndex={0} />
  28. <div aria-activedescendant={someID} tabIndex="0" />
  29. <div aria-activedescendant={someID} tabIndex={1} />
  30. <input aria-activedescendant={someID} />
  31. <input aria-activedescendant={someID} tabIndex={0} />
  32. ```
  33. ### Fail
  34. ```jsx
  35. <div aria-activedescendant={someID} />
  36. <div aria-activedescendant={someID} tabIndex={-1} />
  37. <div aria-activedescendant={someID} tabIndex="-1" />
  38. <input aria-activedescendant={someID} tabIndex={-1} />
  39. ```