Skip to content

fix(docs): version-picker shows selected option on /versions/latest/ (#238) - #247

Merged
Chris-Wolfgang merged 1 commit into
mainfrom
fix/238-version-picker-latest-select
Jul 14, 2026
Merged

fix(docs): version-picker shows selected option on /versions/latest/ (#238)#247
Chris-Wolfgang merged 1 commit into
mainfrom
fix/238-version-picker-latest-select

Conversation

@Chris-Wolfgang

Copy link
Copy Markdown
Owner

Summary

Fixes #238 — the docs-site version dropdown showed no selected option when readers landed on /versions/latest/.

Root cause

docfx_project/public/version-picker.js had a 26-line URL-match "resolution" block that tried to reconcile the latest alias against a concrete vX.Y.Z entry by matching URLs. Those URLs are structurally different by construction — latest's URL is /<repo>/versions/latest/ while concrete entries are /<repo>/versions/vX.Y.Z/ — so the match NEVER succeeded. The picker then fell through to the render loop, which unconditionally skipped the latest entry, leaving no option matching currentVersion === 'latest'. The browser auto-selected the first option, but change didn't fire because the value was already there → the user couldn't navigate anywhere via the picker.

Fix (Option 1 from the issue)

  • Delete the dead URL-match block entirely.
  • Change the render-loop skip from unconditional to conditional so latest shows up as a selectable option only when the reader is on /versions/latest/. On concrete-version pages the skip still applies — no redundant latest + vX.Y.Z pair.
  • -34 / +12 — mostly deletion.

Verification

Ran a self-contained HTML harness against the patched JS with mocked versions.json:

URL Options Selected
/versions/latest/ [latest, v0.3.4, v0.3.3, v0.3.2] latest ✅ (was broken before — no selection)
/versions/v0.3.4/ [v0.3.4, v0.3.3, v0.3.2] v0.3.4
/versions/v0.3.2/ [v0.3.4, v0.3.3, v0.3.2] v0.3.2
any other page [latest, v0.3.4, v0.3.3, v0.3.2] latest ✅ (default)

Change event fires and navigates when a version is picked (verified — dispatching change caused the browser tab to try to navigate).

Fleet-wide

version-picker.js was fanned out from the canonical during the D8 campaign, so every downstream Wolfgang.* docs site has the same broken block. Next bulk-repo-pr sweep should apply this same delete-and-flip patch to all 12 sibling repos plus repo-template.

Closes #238

Bug: the dropdown on /versions/latest/ showed no selected option, because
the picker's URL-match resolution block at renderPicker() lines 59-84 tried
to match `latest`'s URL (/versions/latest/) against concrete version URLs
(/versions/vX.Y.Z/) — structurally different, so the match NEVER succeeded.
The picker then fell through to the render loop, which unconditionally
skipped the `latest` entry, leaving no option matching `currentVersion`.
The browser then auto-selected the first option but change wouldn't fire,
so the user couldn't navigate away.

Fix (Option 1 from the issue): keep `latest` as a first-class option on
/versions/latest/, drop the dead URL-match resolution block entirely.

Changes:
- Delete the 26-line URL-match resolution block that was chasing an
  impossible match. Add a note at the currentVersion default explaining
  that `latest` is the fallback for pages that aren't under /versions/.
- Change the render-loop skip from unconditional
    if (v.version === 'latest') return;
  to conditional
    if (v.version === 'latest' && currentVersion !== 'latest') return;
  so `latest` shows up as a selectable option ONLY when the reader is on
  /versions/latest/. On concrete-version pages the skip still applies —
  no redundant `latest + vX.Y.Z` pair.

Verified locally via an HTML harness that:
- On /versions/latest/          → dropdown shows [latest, v0.3.4, v0.3.3, v0.3.2], `latest` selected.
- On /versions/v0.3.4/          → dropdown shows [v0.3.4, v0.3.3, v0.3.2], v0.3.4 selected.
- On /versions/v0.3.2/          → dropdown shows [v0.3.4, v0.3.3, v0.3.2], v0.3.2 selected.
- On any non-/versions/ page    → currentVersion defaults to 'latest'; dropdown shows all
                                    with `latest` selected.
- change event fires and navigates when a version is picked.

Fleet-wide: version-picker.js was fanned out from the canonical during the
D8 campaign; every downstream Wolfgang.* docs site has the same broken
block. A fan-out of this fix belongs in the next `bulk-repo-pr` sweep —
noted in the InspectCode/docs rollout memory.

Closes #238
Copilot AI review requested due to automatic review settings July 14, 2026 00:23

Copilot AI 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

This PR fixes the DocFX docs-site version dropdown so it correctly shows a selected option when users land on /versions/latest/, aligning behavior with issue #238’s acceptance criteria by removing unreachable “latest alias resolution” logic and rendering latest only when appropriate.

Changes:

  • Removed the dead URL-match “latest → concrete version” resolution block that could never succeed.
  • Updated dropdown rendering to include the latest option only when the current page is /versions/latest/, ensuring the selected option is visible and navigation remains functional.

@Chris-Wolfgang
Chris-Wolfgang merged commit 0456438 into main Jul 14, 2026
9 of 10 checks passed
@Chris-Wolfgang
Chris-Wolfgang deleted the fix/238-version-picker-latest-select branch July 14, 2026 00:52
Chris-Wolfgang added a commit to Chris-Wolfgang/DbContextBuilder that referenced this pull request Jul 26, 2026
…369)

## Summary

Fan-out of [Try-Pattern PR
#247](Chris-Wolfgang/Try-Pattern#247). The
version-picker JS had a dead URL-match resolution block that tried to
match the `latest` alias URL (`/<repo>/versions/latest/`) against
concrete version URLs (`/<repo>/versions/vX.Y.Z/`) — structurally
different by construction, so the match NEVER succeeded. The render loop
then unconditionally skipped the `latest` entry, leaving no option
selected on `/versions/latest/`.

**Fix:** delete the dead resolution block; keep `latest` as a
first-class option ONLY when the reader is on `/versions/latest/`. On
concrete-version pages the skip still applies — no redundant `latest +
vX.Y.Z` pair.

Same patch, same file. Direct fan-out of Try-Pattern's canonical.

## Verification

Try-Pattern PR verified via HTML harness across 4 URL cases; change
event fires and navigates correctly. See [Try-Pattern
#247](Chris-Wolfgang/Try-Pattern#247) for
details.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

[Maintenance] docs: version-picker.js 'latest' URL-match resolution never matches — dropdown broken on /versions/latest/

2 participants