Skip to content

Fix version picker to preserve hash and redirect root build to versioned URL#153

Merged
chinmaymk merged 2 commits intomainfrom
claude/fix-docs-version-picker-RbUcO
Mar 23, 2026
Merged

Fix version picker to preserve hash and redirect root build to versioned URL#153
chinmaymk merged 2 commits intomainfrom
claude/fix-docs-version-picker-RbUcO

Conversation

@chinmaymk
Copy link
Copy Markdown
Owner

Summary

This PR improves the version picker behavior in the documentation site by preserving URL fragments when switching versions and automatically redirecting users from the root build to the canonical versioned URL.

Key Changes

  • Preserve URL hash when switching versions: Modified the onChange() function to include window.location.hash in the target URL and only navigate if the target differs from the current location
  • Add root build detection: Introduced isRootBuild() function to identify when users are on the root /ra/ build (not under /dev/ or /v/ paths)
  • Auto-redirect root build to versioned URL: When the page loads on the root build, the version picker now automatically redirects to the canonical versioned URL using the latest release version, ensuring the picker stays synchronized with the address bar

Implementation Details

  • The hash preservation prevents loss of anchor links when users switch between documentation versions
  • The root build redirect uses window.location.replace() to avoid adding an extra history entry
  • The redirect only occurs after successfully fetching the versions list and confirming a latest version exists

https://claude.ai/code/session_01WY3WpfMhNfZvMULb8NVzxz

claude added 2 commits March 23, 2026 16:03
When visiting the root /ra/ path, the version picker now detects it's
on the unversioned root build and redirects to /ra/v/<latest>/ so the
picker selection stays in sync with the address bar.

https://claude.ai/code/session_01WY3WpfMhNfZvMULb8NVzxz
- Preserve URL hash (anchor) during both root→latest redirect and
  version switches, so deep links like /ra/concepts/#overview work
- Skip navigation when selecting the already-active version to avoid
  unnecessary page reloads

https://claude.ai/code/session_01WY3WpfMhNfZvMULb8NVzxz
@chinmaymk chinmaymk merged commit 13222cd into main Mar 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants