fix: version switcher 404 on non versioned pages#2334
Merged
Conversation
✅ Deploy Preview for expressjscom-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
bbf9655 to
7d89cd8
Compare
jonchurch
commented
May 19, 2026
Comment on lines
-133
to
-144
| getVersion(): string { | ||
| return this.currentVersion; | ||
| } | ||
|
|
||
| setVersion(version: string): void { | ||
| const versionSelects = | ||
| this.sidebar.querySelectorAll<HTMLSelectElement>('[data-version-select]'); | ||
| versionSelects.forEach((select) => { | ||
| select.value = version; | ||
| }); | ||
| this.handleVersionChange(version); | ||
| } |
Member
Author
There was a problem hiding this comment.
These are unused, so I removed them.
bjohansebas
approved these changes
May 24, 2026
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.

closes #2330
Problem
There were two different handlers for version switching, and the buggy one was handling the version switch.
In the "buggy" one, it assumed we were on a versioned page, which was not always the case. So when switching from the blog
en/blog, it would update the URL to be/en/4x/blogand we'd 404Fix
Drop the other dumber handler, wire up the
SidebarVersionManagerto listen to the correct event.The
SidebarVersionManagercorrectly implements the case where we are on a non versioned page and switch versions from the sidebar, it will drop us into the sidebar section we have open at the correct version. But it was listening for the wrong event, so never had a chance to trigger the correct logic.The other handler was dumber and did not have that logic, but was the one handling the event.