dom-testing-library icon indicating copy to clipboard operation
dom-testing-library copied to clipboard

feat(roleHelpers): compute tree implicit arialevel

Open MatanBobi opened this issue 2 years ago • 3 comments

What: Adding the option to implicitly get the aria-level of a treeitem

Why: Resolves https://github.com/testing-library/dom-testing-library/issues/980

How: At the moment, I'm using the naive approach and climb up the tree until I reach a node with explicit role tree.

This isn't ready yet, it's just a draft to see if this approach looks good.

Checklist:

  • [ ] Documentation added to the docs site
  • [X] Tests
  • [ ] TypeScript definitions updated
  • [ ] Ready to be merged

MatanBobi avatar Jan 15 '22 09:01 MatanBobi

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit cd129b6f2b2a06c06e56a8d54277229cb88adadf:

Sandbox Source
react-testing-library-examples Configuration
react-testing-library aria-role tree Issue #980

codesandbox-ci[bot] avatar Jan 15 '22 09:01 codesandbox-ci[bot]

Should I review this considering it's in draft and you said it's not ready yet?

eps1lon avatar Jan 15 '22 20:01 eps1lon

At the moment, I'm using the naive approach and climb up the tree until I reach a node with explicit role tree.

~~Some care needed here (if this is picked up again) as the implicit level (if I’m interpreting correctly) is not necessarily the depth in the DOM tree, but rather the depth in the accessibility tree from the parent node (including concepts such as aria-owns), though aria simply says "document structure" so maybe it’s ambiguous.~~

~~The core aam spec I think clarifies this: "If aria-level is not provided or inherited for an element of role treeitem or comment, user agents implementing IAccessible2 or ATK/AT-SPI MUST compute it by following the explicit or computed RELATION_NODE_CHILD_OF relations."~~

~~In the majority of cases this is likely equivalent, but there are patterns where application of role="presentation" or role="none" complicates things, e.g. see https://www.w3.org/WAI/ARIA/apg/patterns/treeview/examples/treeview-navigation/, or where using groups adds extra DOM hierarchy that need be ignored, e.g. see https://www.w3.org/WAI/ARIA/apg/patterns/treeview/examples/treeview-1a/~~

Adding the option to implicitly get the aria-level of a treeitem

Worth considering listitem, row (but only when in a treegrid), and comment (but only if want to support wai-aria 1.3 which is draft atm) for this as they too have implicit levels.

REF:

  • https://www.w3.org/TR/wai-aria-1.2/#aria-level
  • https://www.w3.org/TR/core-aam-1.2/#mapping_additional_position

Update: on re-read of the implementation, I think this might be all ok (and my concerns r.e. nested already mitigated by the implementation), apologies should read properly first and comment later.

Comment r.e. other roles stands, and suspect would be good to add the more complex nesting examples as test cases.

cmorten avatar Mar 16 '24 09:03 cmorten