-
Notifications
You must be signed in to change notification settings - Fork 184
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
Reset focus after navigation #25
Comments
I saw this interesting tweet thread by Ryan Florence, and we could possibly implement something similar in It's possible to do a very naive focus reset today with pure Svelte: <!-- MyRouteComponent.svelte -->
<script>
import { onMount } from 'svelte';
let domNode;
onMount(() => {
domNode.focus();
});
</script>
<input bind:this={domNode} /> The new |
Focus behavior that isn't completely resetting (non ideal, but workable), is tricky. Would it be useful to do this in two stages? I mean, first reset focus on route, and then second work on something that gives developers more control over where focus should go, so that they can do it intentionally? If so I'm happy to try and submit a PR for this! Related: Marcy Sutton from Gatsby did a number of user tests with client side routing in June, see What we learned from user testing of accessible client-side routing techniques with Fable Tech Labs | GatsbyJS |
I've submitted #95 to reset focus after routing. In the meantime, the Gatsby folks worked on gatsbyjs/gatsby#19290, which has a mechanism that announces routes to screenreader users with a specific announcement component (which really just is an element with some ARIA attributes and relevant content, the announcement itself is done by browser/AT). The “relevant content“ is either page title or first @EmilTholin would you consider a PR that introduces such a route announcement component? I think it would make |
In case they're useful, here are parallel conversations happening in Vue and React land: |
In order to better reproduce browser behaviour on a page refresh perhaps we should also search for the Also there is pesky iOS safari not implementing |
@SteveALee I would tread very carefully with ETA: Back in the dark ages of server-rendered apps, it would have been possible for a user agent to ignore the When it comes to SPAs (putting SSR aside for a moment) the SPA framework would have to emulate the Browser's native You could perhaps imagine some standard or quasi-standard way to expose this setting (perhaps a la † Announcing page load, focus management, restoring scroll position on back button, etc are mostly ignored by SPA authors. |
I have implemented focus management in svelte-navigator (see Router.svelte, Route.svelte and a11y.js), which is based on svelte-routing. I'm sure there is a lot that could be improved, but maybe there is something in there that could help get things started. |
Please reset focus after page navigation. See the following for some resources on the topic:
The text was updated successfully, but these errors were encountered: