-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
feat(core): add aria-current to active links (close #2116) #3073
Conversation
hey @smhigley thanks for the well detailed PR! I think this makes sense and is safe to add as a default for vue router but I was wondering about point 2: applying it to active instead of exact-active. I think the latter makes more sense as a default because it is more likely to end up in one single element marked as It's not directly related but I also wanted to note that active and exact behavior is very likely to change on v4 (vuejs/rfcs#136) and I was going to use exact active to set it. If you have any input for that, please go ahead 🙂 ! |
@posva I updated the PR to add I originally did non-exact active because the tutorials and examples I happened to see seemed to be adding active styles based on the active class, and I was trying to choose whichever would add most parity between visual active styles and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Thank you! 😄 |
Hi! First contributor + pretty new to Vue 👋 😄
This PR adds
aria-current="page"
to active links, and resolves #2116. I made the following two choices:Use
aria-current="page"
over other token valuesThe original issue mentions allowing custom token values, or future
<router-link>
extension possibilities. That still seems useful, butaria-current="page"
seems like the right choice at least 90% of the time. The other tokens are either much less common (e.g.step
) or unlikely to be used with a router at all (e.g.date
)Use the
activeClass
logic over only applying it to the exact active routeThis is more hand-wavy, but seems like the better choice -- URL params shouldn't necessarily affect
aria-current
, and it's not the worst thing to have parent routes also receivearia-current
ifexact
is not applied.I'm hoping this is a small enough change that it can go in before the harder work of figuring out how to extend
<router-link>
is done, and it seems like a sensible default even with customization. I've run into some issues using vue-router b/c of this, so I'd personally love to seearia-current
added :). I'm happy to answer any questions on the accessibility side, and let me know if I missed anything PR-wise. Thanks!