Skip to content
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

[Accordion] a11y not valid when content contains focusable elements #102

Open
titouanmathis opened this issue Dec 8, 2022 · 0 comments
Open
Labels
bug Something isn't working

Comments

@titouanmathis
Copy link
Contributor

When an accordion component has its content hidden, an aria-hidden="true" attribute is added to its container. If the content includes links, buttons or other focusable elements, testing tools such as Lighthouse or Axe will report an error as content hidden with aria-hidden="true" should not contain focusable elements.

Report from Lighthouse
Capture d’écran 2022-12-08 à 15 15 52

More info here: https://dequeuniversity.com/rules/axe/4.4/aria-hidden-focus

This should be fixed by using hidden (which is the correct value) instead of invisible for the visibility CSS property of the container:

diff --git a/packages/ui/molecules/Accordion/AccordionItem.ts b/packages/ui/molecules/Accordion/AccordionItem.ts
index a0cf6a5..e55bed2 100644
--- a/packages/ui/molecules/Accordion/AccordionItem.ts
+++ b/packages/ui/molecules/Accordion/AccordionItem.ts
@@ -119,7 +119,7 @@ export class AccordionItem<T extends BaseProps = BaseProps> extends Base<
    * Update the refs' attributes according to the given type.
    */
   updateAttributes(isOpen:boolean) {
-    this.$refs.container.style.visibility = isOpen ? '' : 'invisible';
+    this.$refs.container.style.visibility = isOpen ? '' : 'hidden';
     this.$refs.container.style.height = isOpen ? '' : '0';
     this.$refs.content.setAttribute('aria-hidden', isOpen ? 'false' : 'true');
     this.$refs.btn.setAttribute('aria-expanded', isOpen ? 'true' : 'false');

Some tests might need to be done when adding transitions to the component.

@titouanmathis titouanmathis changed the title Accordion: a11y not valid when content contains focusable elements [Accordion] a11y not valid when content contains focusable elements Dec 8, 2022
@titouanmathis titouanmathis added the bug Something isn't working label Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant