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

[aria-*] attributes do not match their roles #4910

Closed
4 tasks done
m4g3s opened this issue Jan 24, 2023 · 3 comments
Closed
4 tasks done

[aria-*] attributes do not match their roles #4910

m4g3s opened this issue Jan 24, 2023 · 3 comments
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@m4g3s
Copy link

m4g3s commented Jan 24, 2023

Context

No response

Bug description

Seems to be an issue with [aria-*] attributes not matching their roles. I found this bug when running Chrome's Lighthouse feature.

Screenshot 2023-01-24 at 3 10 11 AM

Seems to be an issue with the nav

Was able to reproduce this error on a reproduction after adding the following to mkdocs.yml

nav:
  - 'Home':
    - 'index.md'
    - 'Test':
      - 'Testing': 'testing.md'

Also will mention i'm using the latest version of insiders 4.29.0

Related links

  • Bug reporting
  • I looked though the documentation but couldn't find anything too relevant to link here

Reproduction

example.zip

Steps to reproduce

  1. go to https://squidfunk.github.io/mkdocs-material/setup/changing-the-colors/
  2. Open developer tools
  3. Run Lighthouse
  4. Check under Accessibility

Browser

Chrome

Before submitting

@squidfunk squidfunk added the bug Issue reports a bug label Jan 24, 2023
@squidfunk
Copy link
Owner

Thanks for reporting and providing the reproduction! The problem is related to. aria-expanded being set on the label element, which doesn't match it's role, and was introduced in f8f44f5 to solve #4804. I check how we can improve the situation.

@squidfunk
Copy link
Owner

Okay, I believe I found a better solution in 148c9fd, at least Lighthouse stopped complaining. Prior to this change, the label element hosted the aria-expanded attribute, which is semantically not correct, since the label itself cannot be expanded. However, the label triggers the expansion of the subsequent nav element, which is why I've linked the nav element to the label using aria-labelledby, and set the aria-expanded attribute on this element.

This fixes the issue described. I've also fixed an issue where the aria-expanded state was only triggered when hitting Enter when thelabel is focused, not when clicking. Now, the attribute is also updated when clicking on the label.

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Jan 28, 2023
@squidfunk
Copy link
Owner

Released as part of 9.0.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

2 participants