accname icon indicating copy to clipboard operation
accname copied to clipboard

Clarification of 2F for descendants of label with concrete role

Open eps1lon opened this issue 5 years ago • 3 comments

The "is a descendant of a native host language text alternative element" in

Otherwise, if the current node's role allows name from content, or if the current node is referenced by aria-labelledby, aria-describedby, or is a native host language text alternative element (e.g. label in HTML), or is a descendant of a native host language text alternative element

-- https://w3c.github.io/accname/#step2F

seems to be ignored by implementors so far (web-platform-tests and NVDA).

Given

<label for="test">
  Flash
  <span role="menu">
    <span role="menuitem">1</span>
  </span>
  times
</label>
<input id="test" type="text" />

the accessible name of #test is expected to equal Flash times according to several web-platform-tests.

As I see it the algorithm follows these steps:

  1. set root node to #test
  2. 2D applies: set current node to label[for="test"]
  3. 2F applies: children are #Text, span[role="menu"], #Text
  4. set current node to #Text
  5. 2G applies: return Flash
  6. set current node to span[role="menu"]
  7. 2F applies (element is "descendant of a native host language text alternative element"): children are span[role="menuitem"]
  8. set current node to span[role="menuitem"]
  9. 2F applies (allows name from content): children are #Text
  10. set current node to #Text
  11. 2G applies: return 1

Now the accumulated text is already Flash 1 and can no longer match Flash times.

Does "allows name from content" include that having a role implies allows name from content? e.g. !role && isDescendantOfTextAlternativeElement(role) || allowsNameFromContent(role)? This would allow e.g. nested <span /> but disallow elements with concrete roles that don't allow name from content and match the web-platform-tests.

eps1lon avatar Nov 12 '19 06:11 eps1lon

If I understand it correctly, role=menu does not meet the condition 2F, but the 2E before it ("control embedded within the label"). Since the control "menu" is not one of these elements from 2E (textbox, button, combobox, listbox, range), the content of the control is ignored. 2F can only apply if it is not a "control embedded within the label".

If my understanding is correct, then the specification lacks a definition of "control" (to make it clear which elements are considered to be control, but whose contents are ignored if they are inside a label)

JAWS-test avatar Nov 13 '19 01:11 JAWS-test

@JAWS-test So you're saying 2E needs a section explaining

  1. what is a "control"
  2. what happens with elements that are not explicitly listed in that step (i.e. which elements to ignore when reaching 2E)

Does this summarize your comment?

eps1lon avatar Nov 13 '19 07:11 eps1lon

  1. Yes
  2. That would be good, but is not absolutely necessary

First, however, others would have to say whether my interpretation is correct at all.

JAWS-test avatar Nov 13 '19 08:11 JAWS-test