-
Notifications
You must be signed in to change notification settings - Fork 75
Handle content-visibility
and hidden="until-found"
#1903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Co-authored-by: Carlos Duarte <carlosapaduarte@gmail.com>
@@ -11,11 +11,12 @@ input_aspects: | |||
An HTML element is _programmatically hidden_ if either it has a [computed][] CSS property `visibility` whose value is not `visible`; or at least one of the following is true for any of its [inclusive ancestors][] in the [flat tree][]: | |||
|
|||
- has a [computed][] CSS property `display` of `none`; or | |||
- has a [computed][] CSS property `content-visibility` of `hidden`; or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong, an element with content-visibility:hidden
is not hidden from the accessibility tree. Its content is, but the element itself isn't. To make this more complicated. Even with content-visibility:hidden
, child nodes can (in Chrome) still be used in the accessible name. For example, not only is the following still a button in the accessibility tree, its accessible name is still "Hello world", even though the text isn't visible.
<button style="content-visibility:hidden">
Hello world
</button>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are various caveats on implementing content-visibility: to avoid screen reader detection:
https://drafts.csswg.org/css-contain/#cv-a11y
And there is an outstanding issue on this:
w3c/csswg-drafts#5857
It may be worth holding off on this until there's consensus on how AT should implement this.
Edit: The spec seems to suggest that what gets exposed to AT depends on timings of CSS layout. They want to avoid AT detection due to slow layout with AT vs. fast layout without AT. There are definitely big timing differences between Firefox (multi-thread, breadth-first CSS layout written in Rust) and Chrome/WebKit (single thread, depth-first layout written in C++)
@dd8 Tried to sum up the discussion about |
#### Inapplicable Example 6 | ||
|
||
This `role` attributes is specified on an element which is [programmatically hidden][]. | ||
|
||
```html | ||
<div hidden role="banner">Some Content</div> | ||
``` | ||
|
||
#### Inapplicable Example 7 | ||
|
||
This `role` attributes is specified on an element which is [programmatically hidden][]. | ||
|
||
```html | ||
<div hidden="until-found" role="banner">Some Content</div> | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd prefer these test cases in different rules. This rule is has been somewhat contested. How about adding the hidden
example to Form field has non-empty accessible name
, and have the image rule above use hidden="until-found"
?
<div style="content-visibility: hidden"> | ||
<img src="/test-assets/shared/w3c-logo.png" /> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until this is better supported I don't think we should add this. This example fails in Firefox and Safari. I think its better to use hidden=until-found here. If you wanted to pass in Chromium you'd still need to support content-visibility, but the example wouldn't be a failure in browsers that don't support it yet. What's also neat specifically about using it in this rule is that there's nothing to be found here, so this couldn't become a visible image through some user action.
<div style="content-visibility: hidden"> | |
<img src="/test-assets/shared/w3c-logo.png" /> | |
</div> | |
<div hidden="until-found"> | |
<img src="/test-assets/shared/w3c-logo.png" /> | |
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hidden="until-fonud"
also seems to have poor support: MDN browser compatibility.
I guess it's best to just park this until there is better support…
- the element has a [computed][] CSS property `visibility` whose value is not `visible`; or | ||
- at least one [ancestor][] of the element has a [computed][] CSS property `content-visibility` of `hidden`; or | ||
- at least one [inclusive ancestors][] of the element has a [computed][] CSS property `display` of `none`; or | ||
- at least one [inclusive ancestors][] of the element has an `aria-hidden` attribute set to `true` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not new to the PR, we could open a separate issue, but this is incorrect I think. If you use aria-owns to grab a node that has an ancestor with aria-hidden, that node itself isn't hidden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's also the conclusion that was reach in this ARIA PR.
I'm recording that in #1991 .
Looks like both |
Parking as draft for now.
Both
content-visibility
andhidden="until-found"
have poor browser support. This means at least that any test case using them would hit an Accessibility Support problem…content-visibility: hidden
to the reasons for being Programmatically Hidden.hidden: until-found
is recommended to be handled viacontent-visibility: hidden
.There are many more rules that indirectly use "Programmatically hidden", because it is mentioned in "Included in the Accessibility tree". And indeed, programmatically hidden elements meet the conditions for being excluded from the Accessibility Tree.
I'm however not sure we need to add examples with these new properties or value on half the ruleset 🤔
OTOH, it may be worth doing it like here with one single Inapplicable Example grouping many cases of exclusion. This does not clutter rules with a lot of extra examples, but still allow to exercice the definition (and it becomes the task of the tool vendors to understand why they fail a given test cases)
Closes issue(s):
Need for Call for Review:
This will require a 2 weeks Call for Review (updating a definition with impact in many rules)
Pull Request Etiquette
When creating PR:
develop
branch (left side).After creating PR:
Rule
,Definition
orChore
.When merging a PR:
How to Review And Approve
f