Using docs routeBasePath="/", navbar version dropdown displays incorrect version on "/"
Have you read the Contributing Guidelines on issues?
- [X] I have read the Contributing Guidelines on issues.
Prerequisites
- [X] I'm using the latest version of Docusaurus.
- [X] I have tried the
npm run clearoryarn clearcommand. - [X] I have tried
rm -rf node_modules yarn.lock package-lock.jsonand re-installing packages. - [X] I have tried creating a repro with https://new.docusaurus.io.
- [X] I have read the console error message carefully (if applicable).
Description
Hi, When routeBasePath option is set to "/", going back to the home page either through the breadcrumb or the root url (company logo) resets the version to the 'current' one, whatever the version we were using.
Reproducible demo
https://doc4d.github.io/docs/19/API/ClassClass
Steps to reproduce
- Go to the page above (v19)
- Click on the company logo or the Home in the breadcrumb
Expected behavior
The home page is displayed with "v19" in the version menu
Actual behavior
The home page is displayed with "v19 R6" (which is the current one) in the version menu
Your environment
- Public source code:
- Public site URL:
- Docusaurus version used:
- Environment name and version (e.g. Chrome 89, Node.js 16.4):
- Operating system and version (e.g. Ubuntu 20.04.2 LTS):
Self-service
- [ ] I'd be willing to fix this bug myself.
Regarding your repro steps: that's not exactly how it's designed to work.
- The "persisted version" is only persisted when the user explicitly clicks on a v19 link (ie selecting that version with the navbar dropdown)
- It is not persisted when "landing" on a v19 page (because it wasn't necessarily an explicit choice? might be SEO indexing? 🤷♂️ )
If you want users landing on v19 pages to make this version become the one displayed on the homepage (instead of the default one being "v19 R6", we don't have an API for that. But you can probably achieve it by swizzling @theme/DocVersionRoot (just merged 1sec ago: https://github.com/facebook/docusaurus/pull/7966, will be in v3.0/canary) and this undocumented api:
import {useDocsPreferredVersion} from '@docusaurus/theme-common';
However, after explicitly selecting v19 with the dropdown, I agree there is still a weird behavior because these 2 versions should normally be in sync:

Thank you for your reply. Yes some users work with the v19 only. I guess they'll keep bookmarks on a v19 landing page for example, and don't want to switch automatically to 19 R6 each time they display the home page. Or they could go to the home page, switch the version then stay in this version for the whole session.