Skip to content

chore: hidden and aria-hidden for nested-interactive#3159

Closed
oscarmarina wants to merge 2 commits intodequelabs:developfrom
oscarmarina:chore/provide-a-semantic-indication-of-content-state-that-indicates-content-is-hidden
Closed

chore: hidden and aria-hidden for nested-interactive#3159
oscarmarina wants to merge 2 commits intodequelabs:developfrom
oscarmarina:chore/provide-a-semantic-indication-of-content-state-that-indicates-content-is-hidden

Conversation

@oscarmarina
Copy link
Copy Markdown

The standard technique for hiding content for all users has been the use CSS display:none. Now, both ARIA and HTML5 also provide a semantic indication of content state that indicates content is hidden or should not be available to users

In nested interactive controls they would have the same behavior if hidden pass the test; aria-hidden=true test would behave in the same way

@oscarmarina oscarmarina requested a review from a team as a code owner September 15, 2021 13:51
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@straker
Copy link
Copy Markdown
Contributor

straker commented Sep 15, 2021

Thanks for the pr. Unfortunately I don't think this works as expected. Using display: none removes the element both visually and from the tab order, while aria-hidden does neither of those. Testing this out in different screen reader / browser combinations:

<div role="button"><button aria-hidden="true">My Button</button></div>
  • IE / JAWS - Can tab to the button and is read as "Unlabeled 0 button"
  • Edge / JAWS - Can tab to the button and is read as "My Button, button", activating the button moves focus off of it
  • FireFox / NVDA - Can tab to the button and nothing is read out, sometimes just "blank"
  • Safari / VO - Can tab to the button and is read as "button" (no label). Furthermore you can press "down" to enter the text and "My Button" is read.

However, as to whether or not this particular case should fail the nested-interactive rule, we'll need @WilcoFiers opinion.

@oscarmarina
Copy link
Copy Markdown
Author

I agree the correct combination would be aria-hidden="true" and tabindex="-1" as explainend in
accessibilityinsights.io → aria-hidden-focus

  • Element with aria-hidden="true" contains only focusable elements that are disabled or not tabbable

For me this is a variant of the same thing but I don't know if you shared this opinion.

@oscarmarina oscarmarina force-pushed the chore/provide-a-semantic-indication-of-content-state-that-indicates-content-is-hidden branch from 056a3d4 to 1323278 Compare September 16, 2021 06:12
@straker
Copy link
Copy Markdown
Contributor

straker commented Sep 16, 2021

So talking with Wilco we determined that since the example fails aria-command-name and aria-hidden-focus, it doesn't also need to fail nested-interactive. Furthermore, since the description of the rule is Nested interactive controls are not announced by screen readers, adding aria-hidden=true passes this description as the button is no longer announced to a screen reader.

Copy link
Copy Markdown
Contributor

@straker straker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Co-authored-by: Steven Lambert <2433219+straker@users.noreply.github.com>
@scottaohara
Copy link
Copy Markdown
Contributor

scottaohara commented Sep 17, 2021

Tested the following snippet with a colleague the other day - with Dragon both checkboxes in the following markup snippet were still exposed;

<div role=checkbox aria-checked=true tabindex=0 aria-label=foo>
  <input type=checkbox aria-hidden=true tabindex=-1> <!-- visually hidden -->
</div>

Using VoiceOver and the down arrow key alone to read line-by-line, the visually hidden checkbox is still reached, causing a focus stop without an announcement.

While screen readers are trying to error correct for author blunders like these, it's not bullet proof across all other AT - more of which still needs testing.

For instance, testing the proposed 'passing' snippet specific to this issue with Edge/Narrator, Narrator can reach the outer button and it will be announced with no name (which makes sense because the 'pass' is within the nested button that's set to aria-hidden=true). Navigating again, Narrator will then reach the nested button (even though it's aria-hidden/tabindex=-1) and announce "pass, button")
https://codepen.io/scottohara/full/wveyWWK

I'd request that this be taken into consideration before passing stuff that can still pose issues, and would not discourage authors from poor coding practices.

Thanks

@WilcoFiers
Copy link
Copy Markdown
Contributor

Apologies for the slowed response. I've been a little reluctant to dive into this. Scott is right in that this pattern just doesn't work very well, and that you probably just shouldn't use it.

I think what needs to happen is that we create a new failure message, specifically to explain that using negative tabindex can still cause problems. I'll create an issue for this.

@straker
Copy link
Copy Markdown
Contributor

straker commented Nov 4, 2021

I believe this pr is replaced by #3194, since we don't want tabindex=-1 to pass but now warn of the problem.

@straker
Copy link
Copy Markdown
Contributor

straker commented Nov 5, 2021

Going to close this issue. Negative tabindex will now produce a warning stating that it won't prevent assistive technologies from focusing the element. In terms of the number of rule failures, I believe all 3 should be reported for the following reason:

If the user starts with this HTML:

<div role="button"><button aria-hidden="true">My Button</button></div>

We report 3 failures: aria-hidden-focus, button-name, and nested-interactive. So the user then does the following to "fix" the problem:

<div role="button" aria-label="My Button"><button tabindex="-1" aria-hidden="true">My Button</button></div>

Which should correctly produce a nested-interactive failure with the message warning of tabindex=-1. If we were to prevent nested-interactive, the user wouldn't know the 2nd solution still has a problem. So it's better that all 3 fail the first time as they are all 3 different problems on the structure.

@straker straker closed this Nov 5, 2021
@oscarmarina oscarmarina deleted the chore/provide-a-semantic-indication-of-content-state-that-indicates-content-is-hidden branch November 5, 2021 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants