-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
[a11y] Route Announcements #20428
[a11y] Route Announcements #20428
Conversation
Announce client-navigation changes. Place focus on relevant content after a navigation change. Tests included.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Cool PR! I's really great that you took the time and effort to put this together, as the impact of inaccessible client-side routing is quite broad with the number of NextJS sites out there. A couple of high-level notes:
The announcements are for screen readers and other assistive technologies, so keyboard users wouldn't really benefit from that detail. Moving keyboard focus is more relevant in that case.
The research of mine that you mentioned recommended that focus should be sent to a small, keyboard-interactive element like a skip link. Sending focus to an h1 or wrapper element works for some aspects, but wasn't really the recommended solution. I also want to make sure visible focus outlines are considered, even if it takes using Lastly, to the Vercel team: I wish this issue hadn't been left to the community to take on as accessibility is an important concern for all framework core teams, and you need to address it. I hope this PR will get the reviews and attention it requires to move forward. |
the example videos seem to be broken - can we fix it? |
Hey @jhackett1 -- Which example videos appear to be broken? The ones in the PR description seem to be working for me. |
Hello, we are using Next 10.2.0 and as I read it, this feature should be available since Next 10.0.9. For some reason, it does not work and still focuses something in the middle of the page upon rendering the new page. We have however a
Do we need to configure anything specific to use the new Edit: I tested with the MacOS VoiceOver for the announcement of the new page. |
Is reliance on Per https://gist.github.com/paulirish/5d52fb081b3570c81e3a, reading Based on their difference seems like it's intentional but it's still nice if there was some way to opt out of the |
I didn’t do extensive tests but my understanding is that This StackOverflow answer explains it nicely with a concise example:
Invisible content within a node could happen for a variety of reasons: it could be added to provide additional context for assistive technologies, it could be an editing artefact from a CMS, it could be an SVG icon or a temporarily hidden anchor link to jump to the It feels like |
Another choice is to make |
I’ve been meaning to issue a pull-request for this since April and I originally didn’t have time and then I simply forgot. But yes, we definitely should, as mentioned in that issue. I’ll put this back onto my radar. This won’t eliminate the issue outlined by Dan though, it will just make it less likely. Edit: done. :) |
…31147) ## Improvement This pull-request should address #24021, improving the page change announcement for assistive technologies by giving priority to `document.title` over `h1`. Interestingly, it would also improve a potential performance bottleneck by skipping calls to `innerText` on the main `h1` raised in [this comment](#20428 (comment)).
Amazing, thank you. |
Route Announcements
Summary
This PR improves the accessibility of NextJS's client-side navigation by announcing route changes to screen readers.
Context
When a user who is sighted clicks on a link, they can see the content change. It's an affirmation that what the user intended to do by clicking a link actually worked! Users navigating the page via a screen-reader will not get this feedback on NextJS sites (This is an issue on many SPA-like architectures).
nextjs-before.mov
Solution
Whenever there is a route change, the new
<RouteAnnouncer />
will look for a name to give the new page and then announce it! The name is found by first looking for anh1
, falling back todocument.title
, and lastly topathname
.<RouteAnnouncer />
is a visually hidden component placed within the<AppContainer />
.Demo
nextjs-after.mov
Inspiration
First and foremost, this PR was inspired by @marcysutton's studies and writing, What we learned from user testing of accessible client-side routing techniques with Fable Tech Labs
as well as @madalynrose's Accessible Routing PR for Gatsby.
There were also learnings gleaned from the conversations within #7681.
Related Issues & PRs