question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[A11y] required-context-role

See original GitHub issue

Rule Requested

The required context role defines the owning container where this role is allowed. If a role has a required context, authors MUST ensure that an element with the role is contained inside (or owned by) an element with the required context role. For example, an element with role="listitem" is only meaningful when contained inside (or owned by) an element with role="list".

Roles to check

Format: role | required context role

  • columnheader | row
  • gridcell | row
  • listitem | group or list
  • menuitem | group, menu, or menubar
  • menuitemcheckbox | menu or menubar
  • menuitemradio | group, menu, or menubar
  • option | listbox
  • row | grid, rowgroup, or treegrid
  • rowgroup | grid
  • rowheader | row
  • tab | tablist
  • treeitem | group or tree

Example(s)

Conformant Code:

<div role="list">
  <div role="listitem">Item One</div>
  <div role="listitem">Item Two</div>
</div>

Non-conformant code:

<div>
  <div role="listitem">Item One</div>
  <div role="listitem">Item Two</div>
</div>

Suggested Error Message

(Replace items in brackets with the item that violated the rule)

“You have an element with the role of {{role}} but it is missing the required (immediate) parent element of {{parent-element-options}}. Reference: https://www.w3.org/TR/wai-aria-1.0/roles#{{role}}.”

Reference(s)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
MelSumnercommented, Jan 24, 2019

@MelSumner can you provide error message for this rule?

Sure, I’ll update the issue to include a suggested error message.

1reaction
rwjbluecommented, Jan 23, 2019

@MelSumner - Can you include example template snippets that would be good/bad (doesn’t need to be exhaustive, but I’d like to make sure we are on the same page).

Read more comments on GitHub >

github_iconTop Results From Across the Web

ARIA required context role[proposed] | ACT Rule | WAI - W3C
This rule checks that an element with an explicit semantic role exists inside its required context. Applicability. This rule applies to any HTML...
Read more >
ARIA required context role - ACT-Rules Community
This rule applies to any HTML or SVG element that is included in the accessibility tree and has a WAI-ARIA 1.1 explicit semantic...
Read more >
ARIA: menuitem role - Accessibility - MDN Web Docs
Associated WAI-ARIA roles, states, and properties. menu role. A widget providing a list of choices. Required context role (or menubar ).
Read more >
WAI-ARIA: Role=Option - DigitalA11Y
Learn the concepts of Accessible Rich Internet Application [WAI-ARIA] & USING THE WAI-ARIA:Option(role) along with accessible code examples.
Read more >
listitem role seems to be missing directory as required context ...
... to write an Accessibility Conformance Testing (ACT) Rule for required context ... Add directory Required Context role to listitem #1062.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found