8000 fix(a11y): Fix ARIA attributes and switch from `div` to `nav` for the explorer by MathieuDR · Pull Request #1972 · jackyzha0/quartz · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(a11y): Fix ARIA attributes and switch from div to nav for the explorer #1972

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

Open
wants to merge 4 commits into
base: v4
Choose a base branch
from

Conversation

MathieuDR
Copy link

The ARIA attributes didn't have correct values and/or labels on the explorer & TOC components.

The aria-controls should refer to an ID reference and not a class like it currently was, this is fixed for both the TOC and explorer.
Some buttons didn't have a correct label because there was no direct text-node child, fixed with either aria-label or aria-labelledby.

I've taken the liberty to change the classes that the aria-controls referred to into ID's. This could be considered a breaking change, some people's styles might refer these classes instead of ID's. I'm not opposed in keeping these classes around if we want to mitigate this.

I've also added a data-* attribute on the overflow list instead of the id. This is so we could accommodate for the id that aria-controls require on the TOC.

Lastly I've changed the explorer root element to a nav as it resembles the main navigation, which greatly helps screen readers as well.

Valid ARIA attributes sources

@MathieuDR MathieuDR marked this pull request as draft May 10, 2025 22:40
@@ -116,7 +117,7 @@ export default ((userOpts?: Partial<Options>) => {
<polyline points="6 9 12 15 18 9"></polyline>
</svg>
</button>
<div class="explorer-content" aria-expanded={false}>
<div id="explorer-content">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A while back all components were changed to use classes over id's to allow non-atomic usage.

Copy link
Author
@MathieuDR MathieuDR May 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean, but the issue with this is that aria-attributes actually requires id's and don't work with classes.
One way to deal with this would be to generate an id for these components, just like the Overflow list did.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except they don't. They require a unique identifier field per tag. This does not have to be the id field.

Copy link
Author
@MathieuDR MathieuDR May 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think that aria-controls requires the id tag of the element. Here are the specifications

aria-controls specification
Id reference list value type

This element in particular requires it because the button has aria-controls="explorer-content".

HTML element concept, where if you scroll down you see what the unique identifier is according to the dom.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, but that still doesn't address the issue I raised.

Your proposed changes remove the classes and add id's. Removing the classes will break component functionality.

In addition, id's must be unique for aria to function properly, per your own sources. Currently, components are non-atomic. If you want to add id's for the purpose of accessibility, please ensure uniqueness in case of multiple components of the same type. (Ideally consistent as well, e.g. no random generated appended text.)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, Like I said I could generate them if you want to support multiple of the same component.
It would also require the inline script to change a bit so it targets the correct one, but I think we can manage that.

Copy link
github-actions bot commented May 10, 2025
built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
quartz ✅ Ready (View Log) Visit Preview ac1c0a2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0