Move the editor's URL state onto react-router - #1325
Merged
Conversation
|
Preview build will be at |
| export const createRouter = () => | ||
| createBrowserRouter( | ||
| [ | ||
| { |
Collaborator
Author
There was a problem hiding this comment.
You might expect 404 handling but this matches current behaviours.
microbit-matt-hillsdon
force-pushed
the
react-router
branch
2 times, most recently
from
September 11, 2026 16:30
86640fc to
d7fa324
Compare
Replaces the bespoke pushState/popstate router with react-router 7, as ml-trainer uses, ahead of adding pages beyond the editor. URLs are unchanged: the editor stays at the base URL with the documentation tab and anchor as optional path segments, and deeper paths remain the editor with no tab selected. - urls.ts holds the basename (derived from the Vite base URL) and the editor route path and link builder, used for both routes and links. - router.tsx creates the router. The root route wraps its outlet in the existing ErrorBoundary, so an uncaught render error shows the content-load-error message rather than unmounting the whole app. - router-hooks.tsx keeps the useRouterState/useRouterTabSlug API over useParams/useNavigate/useLocation. Focus travels in history state and the state identity is tied to location.key so navigating to the same anchor again re-runs scroll and focus effects, as before. - Search results use react-router's Link so the href respects the basename (the old toUrl produced a broken absolute URL). - The sidebar only resets the anchor when the clicked tab is the current one. It previously reset whenever an anchor was set and relied on the old router having updated state synchronously between pointer-up and click; with react-router that made clicking another tab from a deep link land on the current tab's top level.
microbit-matt-hillsdon
force-pushed
the
react-router
branch
from
September 11, 2026 16:36
d7fa324 to
164d951
Compare
Collaborator
Author
|
I'm going to merge this to help unblock some other work but @microbit-robert please can you review retrospectively. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces the bespoke pushState/popstate router with react-router 7, as ml-trainer uses, ahead of adding pages beyond the editor. URLs are unchanged: the editor stays at the base URL with the documentation tab and anchor as optional path segments, and deeper paths remain the editor with no tab selected.