Configure RouteAnnouncer
to announce custom values
#35191
Unanswered
sylvhama
asked this question in
Ideas / Feature Requests
Replies: 1 comment
-
Hi! Thanks for the suggestion. I've moved this to feature requests as currently as it stands I don't think it's a bug but a feature request. What you're proposing is basically this WIP PR that we never managed to merge: #26376 It's a stale PR at this point and it probably should be re-opened and updated but the core of the PR is still what we want to do. Would you be interested in picking this up? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Preliminary Checks
Description
We should be able to tell to the RouteAnnouncer what string to use when our website or web app has a static h1 that does not change after navigating to a new page.
I've made a draft PR to illustrate a potential solution. The idea would be to check for a specific id first. If it's not there then we could default to the current logic. This is not the most elegant way, but since each website / web app has its own HTML structure, this would give the freedom to choose the element that contains the new page title without having to import a custom hook or another component. E.g. on my personal website I have a visually hidden h2: https://github.com/sylvhama/shamann-gatsby/blob/master/src/components/Section.js#L14.
Let me know if that direction would be okay, I would be more than happy to polish my draft PR.
Another more complex idea would be to create a
RouteAnnouncerContext
that would have a state value storing the string rendered within the live region. Then in each page we could call a custom hook (useRouteAnnouncer
) triggering a side effect to change the state.Reproduction Link
https://gatsbystarterdefaultsource.gatsbyjs.io/
Steps to Reproduce
Expected Result
We should hear the content of the second
h1
e.g. "Navigated to Gatsby supports TypeScript by default!".Actual Result
It will announce "Navigated to Gatsby Default Starter" after the first navigation then it won't announce anything else.
Environment
Config Flags
No response
Beta Was this translation helpful? Give feedback.
All reactions