Skip to content

docs: default version selector to Cloud (Latest)#2703

Merged
claudiacodacy merged 1 commit into
masterfrom
fix/version-selector-default-latest
Jul 16, 2026
Merged

docs: default version selector to Cloud (Latest)#2703
claudiacodacy merged 1 commit into
masterfrom
fix/version-selector-default-latest

Conversation

@claudiacodacy

@claudiacodacy claudiacodacy commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Problem

On the released docs.codacy.com, the version selector defaults to the last entry (Self-hosted v2.0.387 (Deprecated)) instead of Cloud (Latest).

Root cause: versions.json lists the latest entry last, and generateVersionSwitcher moves the freshly built <option> elements into the pre-existing #version-selector in the header via replaceChildren. Moving the option nodes loses the selectedness set on them, so the browser's reset falls through to the last option in the list.

Fix

After populating the options, set select.value to the resolved current version so the correct entry stays selected — Cloud (Latest) on the cloud site, and the matching version on self-hosted/versioned paths.

Verification

Reproduced against the live site DOM: the selector reported selectedIndex: 33 (the deprecated last option). Applying select.value = "latest" moved it to selectedIndex: 0Cloud (Latest), which is what this change does deterministically for every version path.

🤖 Generated with Claude Code

@claudiacodacy
claudiacodacy requested a review from a team as a code owner July 16, 2026 08:54
@codacy-production

Copy link
Copy Markdown
Contributor

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the version selector script in docs/assets/javascripts/version-select.js to explicitly set the selector's value to the current version. This prevents the browser from falling back to the last option when option elements are moved into the pre-existing select element. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Set select.value to the resolved current version after populating the
options so the correct entry stays selected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@claudiacodacy
claudiacodacy force-pushed the fix/version-selector-default-latest branch from 30c1dc5 to 7c1cae2 Compare July 16, 2026 08:55
@claudiacodacy
claudiacodacy enabled auto-merge (squash) July 16, 2026 08:55

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

The PR addresses the bug where the version selector would default to older or deprecated entries rather than 'Cloud (Latest)'. While the implementation fixes the UI state management issue by explicitly setting the selector value after DOM injection, there is a risk of a runtime crash if the configuration data is malformed or if the current path does not match expected version patterns.

Additionally, the PR lacks automated test coverage for the selection logic. Verification currently relies on manual path testing, which increases the risk of regression given the sensitivity of URL-based versioning logic. The Codacy analysis indicates the changes are up to standards from a static analysis perspective, but the logic issues detailed below should be addressed before merging.

About this PR

  • The PR lacks automated unit or integration tests to verify the version selection logic across different URL paths or JSON response scenarios. Given the complexity of version matching, automated tests are recommended.

Test suggestions

  • Verify that when the current path corresponds to VERSION_LATEST, the 'Cloud (Latest)' option is selected after initialization.
  • Verify that when the current path corresponds to a specific version found in versions.json, that specific version is selected.
  • Verify that the selector remains enabled and selectable after the version is set.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify that when the current path corresponds to VERSION_LATEST, the 'Cloud (Latest)' option is selected after initialization.
2. Verify that when the current path corresponds to a specific version found in versions.json, that specific version is selected.
3. Verify that the selector remains enabled and selectable after the version is set.

TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback

Comment thread docs/assets/javascripts/version-select.js
@github-actions
github-actions Bot temporarily deployed to Netlify July 16, 2026 08:56 Inactive
@claudiacodacy
claudiacodacy merged commit c5dce13 into master Jul 16, 2026
5 checks passed
@claudiacodacy
claudiacodacy deleted the fix/version-selector-default-latest branch July 16, 2026 09:02
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