Siteimprove / alfa

:wheelchair: Suite of open and standards-based tools for performing reliable accessibility conformance testing at scale
MIT License
102 stars 11 forks source link

Implement SIA-R58 #711

Open Jym77 opened 3 years ago

Jym77 commented 3 years ago

See: Siteimprove/sanshikan#131. It depends on the following 5 rules, all of which apply to entire HTML documents:

These rules all share the same method for locating the main content of a document:

  1. If a perceivable main landmark exists, that landmark is the main content of the document.
  2. Ask main-content for the document.
kasperisager commented 3 years ago

Putting this back in todo until we have a clear implementation plan. From the looks of it, this will be a mostly manual rule.

kasperisager commented 3 years ago

@Jym77 I've outlined my thoughts on the implementation of these rules. Let me know what you think!

Jym77 commented 3 years ago

I think that makes sense.

Jym77 commented 3 years ago

@kasperisager actually, about the repeated blocks bits…

The intention of these rules was to jump to main content, Wilco insisted during review that this was both not really unambiguous and not correct for WCAG that requires jumping to after repeated blocks, no matter where this is (I'm not sure I'm fully convinced…)

Anyway, we could replace all the destination detections (so, essentially, the repeated content detection) by a main content detection similar to what we have in R87. That should be easier since it can be automated if there is a main landmark… Essentially, we'd be implementing the rule at that point: https://github.com/act-rules/act-rules.github.io/blob/33701252f7258b2203c9cafeaf8941cbbdfcd2a1/_rules/bypass-blocks-cf77f2.md (under the assumption that the main block of content is not repeated and after repeated content, note that https://github.com/act-rules/act-rules.github.io/blob/33701252f7258b2203c9cafeaf8941cbbdfcd2a1/_rules/block-collapsible-3e12e1.md still need to know about repeated content and passes if there is none).

Also, note that https://github.com/act-rules/act-rules.github.io/pull/1539 took the same path (for the same reasons), so our Sanshikan rule R87 is already diverging from the ACT rule in this way.

kasperisager commented 3 years ago

Oh, that's a great point! I'm not convinced either that WCAG doesn't actually talk about "main content"; it's the only thing mentioned in the understanding document after all 🤷 Let's do that then 👍

kasperisager commented 3 years ago

@Jym77 I've updated the descriptions accordingly.

Jym77 commented 3 years ago

Another thought… At some point during the writing of the rules, there was a "page has no repeated content" rule which was ultimately dropped since "collapsible blocks" already passes on pages with no repeated content.

However, adding it, while redundant, could greatly help direct reviews for knowledgeable users: if you know the page has no repeated content and see a potential issue "does the page have repeated content?" you can review it quickly and get the rule to pass.

In the current state of the rule, that could be a simple boolean question, and that could be skipped if we see no perceivable content before main. (and of course we don't care if one of the other rules passes) So that would be a quick way out for page with no main landmark and no repeated content.

Similarly, we could add the "page has no repeated content" rule to the skip links rule (making it a composite rule). That would help remove some corner cases where we flag pages that don't need skiplink at all (I've had a question from support, I think it was a EULA page with nothing more than the EULA in the page (no header, nothing)).

Also, we should adapt the skip link rule in a fashion similar to what is suggested here: if there is no perceivable content before main, we don't care about skip link. That does require changing the order of the questions (ask main-content before asking where is the skiplink) in order to get full benefit from it.

kasperisager commented 3 years ago

There wouldn't be a need to introduce such a rule with the plan I've currently outlined though. If you answer "none" to main-content for a particular page, or point to main content where there exists no additional content before it, then all rules will pass.

Jym77 commented 3 years ago

Yes, and that exactly why such a rule was dropped in ACT rules too.

The point is that it might be more intuitive for users reacting "But, there is no repeated content on that page! False positive!" to review a potential issue called "Does the page contain repeated content?" than any of the other potential issues. (but maybe we need some discussion with UX before doing that)

kasperisager commented 3 years ago

Ah, gotcha! That's of course a good point. It does depend on that particular rule being presented before the other rules in an interface.

Jym77 commented 3 years ago

Yes, the atomic rules are currently presented in random order (SIA number). I've already had discussion with May about changing that (since in other composite rules it can also change a lot of the user experience…) Definitely requires some UX thinking, so maybe best kept as an idea for later…

kasperisager commented 3 years ago

We can add it if the need arises, yes 👌

offsetChris commented 3 years ago

Hello, Adding some thoughts here to consider for this rule.

This has come up multiple times with customers, but enforcing that the first focusable element on the page is a skip link seems arbitrary and won't match all websites. In fact it is almost dictating the design of the page insisting that the repeated content is at the top of the page. I would suggest removing this requirement from the check, or having some way of dismissing it. For instance if I have a single page website that does not have repeated content, I should not be required to have a skip link.

<body>
  <main>
    [all the website content]
  </main>
</body>

I have also seen sites that provide the repeated content at the bottom of the page only where all the navigational links are in the footer.

<body>
  <main>
    [website content]
  </main>
  <footer>
   <nav>
     [navigation links]
   </nav>
  </footer>
</body>

There was also a recent example of a website that required users to enter their location (zip code in the US) for the page to reflect the exact products available in their location. It makes sense that this would be the first element the user should interact with because it dictates the rest of their user experience in the site.

<body>
  <header>
    <div role="dialog">
      <form>
        <label> Where are you located? <input type="text"> </label>
        <button type="submit">Submit</button>
      </form>
     </div>
  </header>
</body>

I also think requiring the destination of the skip link to have a role="main" is not consistent with the success criterion, and I think the guidance document refers to the main content of the page in a generic way, not as a literal role="main" way. The bypass blocks success criterion is really only saying the link needs to "skip repeated content" an example of repeated content in the main might be a product page with a bunch of filter options at the top of the content page. These elements are optional to interact with, a user can skip them and get equal value from the page.

<main>
  <div class="filters">
    [product filter elements, likely form elements]
  </div>
  <div id="products>
    [product listings that reflect the filter elements]
  </div>
</main>

In this case I would assume the following regarding a skip link

<main>
  <a href="#products">Skip to products</a>
  <div class="filters">
    [product filter elements, likely form elements]
  </div>
  <div id="products>
    [product listings that reflect the filter elements]
  </div>
</main>

Essentially there is no requirement for websites to have repeated content at the top of the page, so requiring that the skip link must be at the top of the DOM, and direct users to the <main>content is far too strict and is causing many issues with customers. Happy to discuss further, let me know if you have any questions!

offsetChris commented 3 years ago

Thinking about it further, a keyboard user wouldn't necessarily care that the skip link's destination is the <main> landmark. A screen reader can utilize the built in landmark lists to move to that role, so saying that the skip link's destination must be a <main> landmark seems really irrelevant to me.

Jym77 commented 3 years ago

Hello, thanks for the input (and sorry in advance for the loooong answer…)


This has come up multiple times with customers, but enforcing that the first focusable element on the page is a skip link seems arbitrary and won't match all websites. In fact it is almost dictating the design of the page insisting that the repeated content is at the top of the page. I would suggest removing this requirement from the check, or having some way of dismissing it.

Yes. This is why R87 (skip link as first focusable) is only a best practice rule. There are many ways to satisfy 2.4.1 and having a skip link is only one of them. R58 (which we haven't implemented yet) should contain all these ways. Obviously R58 and R87 share many aspects. Currently, we only have R87, and the platform is not making a lot of differences in showing conformance issues and best practices. So it does indeed look a bit like we claim that not having a skip link is a conformance issue. But this is not the case. Hopefully, this will get better once R58 is implemented. We might also consider a way to let users exclude a single rule from their site target (we've been discussing this internally). So that organisations who rely on something else than skip links to satisfy 2.4.1 don't get "punished" by seeing a lot of R87 issues.


For instance if I have a single page website that does not have repeated content, I should not be required to have a skip link.

<body>
  <main>
    [all the website content]
  </main>
</body>

I have also seen sites that provide the repeated content at the bottom of the page only where all the navigational links are in the footer.

<body>
  <main>
    [website content]
  </main>
  <footer>
   <nav>
     [navigation links]
   </nav>
  </footer>
</body>

Yes, both of these cases are currently failing R87 and shouldn't really do it. This is because we do not currently detect if there is anything before the main content.

For R58, all the rules descriptions in the first message pass if there is no content before the main content. So these examples would pass R58 once it is implemented. I fully agree that once we do have a detection of stuff before the main content, we should go back and upgrade R87 to also pass these cases.


There was also a recent example of a website that required users to enter their location (zip code in the US) for the page to reflect the exact products available in their location. It makes sense that this would be the first element the user should interact with because it dictates the rest of their user experience in the site.

<body>
  <header>
    <div role="dialog">
      <form>
        <label> Where are you located? <input type="text"> </label>
        <button type="submit">Submit</button>
      </form>
     </div>
  </header>
</body>

This one is a bit tricky. Cookies banners have a similar issue (they may steal focus). I agree that forcing these before any other content is really accessed is OK. Mostly because they are shown only once per website, and remembered during all the navigation. The ACT rules are currently having an assumption that such banners have been dismissed before the rule is evaluated. However, it is not possible on Alfa side to actually dismiss the banners 😞 We only work with whatever data the crawler is giving us. This definitely causes issues. On top of the very specific issue for these rules, this can create a more general problem if the banner is essentially covering the page, hiding everything, and everything behind has been disabled until the banner is handled. If Alfa is given a page where such a banner is present, it will check the banner but run little to no checks on the actual page which is "in the background" (to some extend).

I am not sure how to solve this issue. I do not know if crawler can be configured to dismiss such banner (on a site by site basis, I guess). This is, I think, an issue affecting much more than just R58 and R87 😖 (for example, https://www.puzzle-sudoku.com/ is displaying a huge cookies banners, shadowing everything (poor contrast to the text) and disabling every button; it would be most untrue to check accessibility on this page when the banner is on (or rather, it would check accessibility of the banner, not of the page) (Alfa might end up just ignoring everything but the modal, not sure, but that is still a problem if the modal is crawled on every page, then Alfa checks the modal hundred of times but none of the pages))


I also think requiring the destination of the skip link to have a role="main" is not consistent with the success criterion, and I think the guidance document refers to the main content of the page in a generic way, not as a literal role="main" way.

R87 (and R58 once implemented) is using the role as an heuristic only. That is:

  1. If there is an element with a role of main, Alfa assumes it is the "main content" (in the WCAG sense of the term).
  2. Otherwise, Alfa asks the users "Where is the main content?"

So Alfa does not require any role on the destination and

<a href="#main">Skip to main content>
<div id="main">Main content</div>

Will pass R87 (and R58). It will require a review (Alfa cannot guess where the "main content" is and will ask user), but it will pass once the review is done.

Note, however, than having an element with a role of main is a good idea in general, and this heuristic gives users a nice bonus if they do it in requiring one less review 😉 If users complain about having to tell NextGen where the "main content" is, we can teach them to use the <main> element and build better pages.


The bypass blocks success criterion is really only saying the link needs to "skip repeated content" an example of repeated content in the main might be a product page with a bunch of filter options at the top of the content page.

There has been quite a lot of discussion around that in the ACT rule… SC 2.4.1 is only mentioning "repeated content", indeed. But its understanding document is consistent in saying that the intent and benefit of it is easy navigation to the "primary content" or "main content". ACT rule chose to stick with the strict text of the SC and requires way to jump to "non-repeated content after repeated content". Alfa decided to align more with the Understanding document and requires way to jump to "main content"; under the assumption that the "main content" is indeed not repeated, this is OK (and also that it is after repeated content, as discussed above this is something Alfa still needs to test…) Among other reasons for this choice, semi-automated detection of "main content" is fairly easy, while semi-automated detection of repeated content is fairly complex…


These elements are optional to interact with, a user can skip them and get equal value from the page.

<main>
  <div class="filters">
    [product filter elements, likely form elements]
  </div>
  <div id="products>
    [product listings that reflect the filter elements]
  </div>
</main>

In this case I would assume the following regarding a skip link

<main>
  <a href="#products">Skip to products</a>
  <div class="filters">
    [product filter elements, likely form elements]
  </div>
  <div id="products>
    [product listings that reflect the filter elements]
  </div>
</main>

Yes, I do agree that these need a skip link at least for user experience. I am not completely sure for WCAG 🤔 Actually, it might be that the <div class="filters"> is not really part of the "primary content" but more of a search or navigation bar and should just be moved out of the <main> element. I guess interpretation varies a lot here…

In any case, it is hard to flag the first case without flagging too many false positives. It would require a way to detect that the <div class="filters"> is indeed repeated among other pages from the site. Automated detection of this is extremely hard. Asking question on every page to point to repeated sections is simply not doable in terms of user experience. So we prefer to let Alfa pass this case rather than fail (or require review) on a ton of other cases. As often, the rule (both ACT rule and Alfa) needs to be complemented with manual testing before approving that the page satisfies the SC.


Essentially there is no requirement for websites to have repeated content at the top of the page, so requiring that the skip link must be at the top of the DOM,

Yes, this is a known caveat of R87 that we plan to solve as part of R58. Also, note that R87 requires the skip link to be the first focusable element, but not necessarily at the top of the DOM; there could be an announcement bar before the skip link (that screen readers would read) without problem as long as it does not contain any focusable element… Of course, most of these announcement bars tend to have focusable element (e.g. Breaking news: bla bla <a href="/breaking.html">Read more</a>) so this is a bit theoretical…

and direct users to the <main>content is far too strict and is causing many issues with customers.

As I said, this should be OK. Maybe the texts in the platform are not clear enough (feel free to report them whenever you see them), but Alfa is looking for the "main content" (WCAG sense); uses an element with a role of main if any, as an heuristic; and ask user if none. So this does not forces users to have a <main> element. Of course, if they have a <main> element that does not contain the "main content", then Alfa is completely thrown off. But this is also a very bad use of semantic HTML (and roles) and should be fixed anyway…

Jym77 commented 3 years ago

Another thought… At some point during the writing of the rules, there was a "page has no repeated content" rule which was ultimately dropped since "collapsible blocks" already passes on pages with no repeated content.

Thinking about that again 🤔

  1. All the atomic rules, as currently suggested, start with "the rule expect that there is no perceivable content before the main content, or …" => that is strongly directing us toward having a separate atomic rule to check that (rather than quadruplicate the test), especially since the composite rule is just a big disjunction (rather do "A or B₁ or B₂ or B₃ or B₄" than "(A or B₁) or (A or B₂) or (A or B₃) or (A or B₄)").
  2. The current ACT rules draft for R87 is moving toward having a "no repeated content" split (atomic 1: no repeated content, atomic 2: skip link; composite: no repeated content or skip link) since failing pages with no repeated content makes little sense (and we have witnessed customer pages with, say, just an EULA that were failing R87 for no good reason). This may still change five times before it gets published, of course…

So, it feels we'd actually benefit from having such an atomic rule. I think it is better to get the more correct "no repeated content" rather than "no perceivable content" and Alfa could test first if there is no perceivable content (then pass automatically), else ask for help (and if Nemo knows about shared segments, it may help answering automatically…) With that, a page that has no perceivable content before <main> would automatically pass the composite rule 👍

So, we'd have:

Jym77 commented 2 years ago

Need to try and make ure that passing R87 also passes R100 without need for new questions.