Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using docs routeBasePath="/", navbar version dropdown displays incorrect version on "/" #7974

Open
6 of 7 tasks
arnaud4d opened this issue Aug 18, 2022 · 2 comments
Open
6 of 7 tasks
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@arnaud4d
Copy link

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • 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

  1. Go to the page above (v19)
  2. 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.
@arnaud4d arnaud4d added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Aug 18, 2022
@slorber
Copy link
Collaborator

slorber commented Aug 18, 2022

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: #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:

CleanShot 2022-08-18 at 17 54 02@2x

@slorber slorber removed the status: needs triage This issue has not been triaged by maintainers label Aug 18, 2022
@slorber slorber changed the title Using "/" as routeBasePath resets the version in the home page Using docs routeBasePath="/", navbar version dropdown displays incorrect version on "/" Aug 18, 2022
@arnaud4d
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

No branches or pull requests

2 participants