ryersondmp / sa11y

Sa11y is an accessibility quality assurance tool that visually highlights common accessibility and usability issues. Geared towards content authors, Sa11y straightforwardly identifies errors or warnings at the source with a simple tooltip on how to fix them.
https://sa11y.netlify.app
Other
284 stars 44 forks source link

Run Sa11y on another checkRoot #79

Closed RobLoach closed 7 months ago

RobLoach commented 8 months ago

Is it possible to run Sa11y on a different element?

I tried setting he checkRoot to something like .sa11y-active, and then changing where the class is, and then running...

sa11y.resetAll();
sa11y.checkAll();

But it doesn't seem to see that the active element moved and that there's a new target checkRoot.

adamchaboryk commented 8 months ago

Hi @RobLoach, as of 3.1.4 it will be! Thank you for the suggestion; I can see how this could be beneficial for SPAs.

I will also include the ability to pass in alternative selectors into checkRoot after instantiation. E.g.

const sa11y = new Sa11y.Sa11y({
    checkRoot: '.sa11y-active',
});

setTimeout(() => {
      sa11y.resetAll(false);
      sa11y.checkAll("main", "main"); // Updates checkRoot and readabilityRoot
}, 800);

P.S. if you pass in false into resetAll(false) the panel won't re-paint.

Here's a little demo:

Video alt: Anytime checkAll(); is called, Sa11y will re-check the specified selector within checkRoot, even as the selector moves from one element to another. The blue border represents the current target area.

https://github.com/ryersondmp/sa11y/assets/26335725/2f7bfae8-c51a-49e4-a01f-23451b109119

RobLoach commented 8 months ago

That's great to hear! I'll be able to do some testing on the 3.1.4-dev branch you have up next week :+1:

Is there anything else you'd like help with?

adamchaboryk commented 8 months ago

Great! I'll hold off on releasing 3.1.4 if you'd like to do some testing yourself then. Here's my test page specifically for this: http://localhost:8080/docs/demo/en/traveling-root.html

Is there anything else you'd like help with?

Nothing that I can think of at the moment. Thank you for asking!

RobLoach commented 7 months ago

It worked! Beautifully done.

Set Sa11y to run on .sa11y-active, and then changed where .sa11y-active is targeting, and then ran the the following, and it worked perfectly. Thanks so much, @adamchaboryk!

sa11y.resetAll();
sa11y.checkAll();
adamchaboryk commented 7 months ago

Shipped! Thank you for the suggestion, @RobLoach.