Today's newsletter is sponsored by ConfigCat — the feature flag service that helps you release features faster and with less risk. More on them at the end of today's newsletter. One of the big things SPAs often mess up is focus management. When a user moves from one page to the next on a classic server-rendered app or website, focus automatically shifts to the top of the document and the new page title is announced to screen readers. SPA routers often break this, leaving visually impaired and keyboard users "stranded" in the middle of a page. I recently worked on a project with React Router, which I thought handled this automatically, but for some reason was not in my app (not sure if it was a config issue or the behavior changed when they merged with Remix). (Yes, this is a React tutorial. Hell has frozen over!) There are a lot of ways to handle this, but in user testing, Marcy Sutton found that the generally most well received approach was the shift focus to the This both puts the user back at the top of the page and announces the page title (assuming the I wrote a small little custom React hook for automating this in React Router.
Inside whatever Component generates your page or app layout, run it to automatically handle focus shifts.
I also added a little CSS to only show a focus ring around the heading for users who navigate by keyboard (or for whom the browser otherwise decides would benefit from it).
I was skeptical about the Are you looking for a service to support dynamic feature flags? ConfigCat is a cross-platform LaunchDarkly alternative that's easy to learn and quick to set up. With SDKs for 19 platforms — including JavaScript, Python, Ruby, Java, and even Rust — you can toggle features on or off without redeploying. ConfigCat subscriptions are the same price regardless of your team size. Get 25% off any paid plan with code Cheers, Want to share this with others or read it later? View it in a browser. |
0 Komentar untuk "[Go Make Things] Shifting focus on route change with React Router"