[Bug] reach router not always setting focus on route change
See original GitHub issueEnvironment
System:
OS: macOS High Sierra 10.13.6
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Memory: 75.43 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 11.10.1 - /usr/local/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
npm: 6.7.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Browsers:
Chrome: 73.0.3683.103
Firefox: 64.0
Safari: 12.1
npmPackages:
react: ^16.8.2 => 16.8.6
react-dom: ^16.8.2 => 16.8.6
react-static: ^7.0.0 => 7.0.9
react-static-plugin-reach-router: ^7.0.0 => 7.0.8
react-static-plugin-sitemap: ^7.0.0 => 7.0.8
react-static-plugin-source-filesystem: ^7.0.0 => 7.0.8
npmGlobalPackages:
react-static: 7.0.9
Steps to Reproduce the problem
With a fresh basic react static installation
- click on
home
(link remains focused) - click on
about
(link remains focused) - click on
dynamic
(content gets focused) - click on
about
(content gets focused) - click on
home
(link remains focused)
Expected Behavior
The router wrapper div should ALWAYS get focused <div tabindex="-1" role="group" style="outline: none;">
You can use a simple CSS rule to quickly visualise this:
*:focus {
background-color: yellow;
}
If you place a couple of components directly inside of <Router>
- instead of the react static <Routes>
component - you will notice that the router placeholder always gets the browser focus
<Router>
<SomeComponent path="/foo" />
<SomeComponent path="/bar" />
</Router>
Notes
I’m under the impression this is due to the way <Routes>
is rendering the static routes, maybe because of the wrapping <Location>
component.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
SPA Accessibility - focus not reset when route changed · Issue ...
I am using a screen reader to interact with my application. Moving between routes does not reset the focus, which would occur on...
Read more >Stop Reach Router scrolling down the page after navigating to ...
Try using <Router primary={false}> which will not focus on the route component. Defaults to true. Primary Routers will manage focus on location ...
Read more >Accessibility - Reach Router
Reach Router provides out-of-the-box focus management so your apps are significantly more accessible without you breaking a sweat. When the location changes, ...
Read more >Accessibility Improvements to Client Side Routing in Gatsby
We recently released accessibility improvements to client side routing in Gatsby core, building on previous focus management improvements ...
Read more >Router | RedwoodJS Docs
Sets can take a private prop which makes all Routes inside that Set require authentication. When a user isn't authenticated and attempts to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just FYI, meanwhile I completely dropped reach-router because I can’t live with the extra divs injected in my markup
Since
@reach/router
will be deprecated (new react-router will merge the two) and I believe this is in that package, I’ll close this for now.