diff --git a/docfx_project/public/version-picker.js b/docfx_project/public/version-picker.js index d5afe387..93a0d9e5 100644 --- a/docfx_project/public/version-picker.js +++ b/docfx_project/public/version-picker.js @@ -49,40 +49,19 @@ } function renderPicker(versions) { - // Detect the currently-viewed version from the URL. - var currentVersion = 'latest'; + // Detect the currently-viewed version from the URL. Only a + // /versions// path names a concrete version; the literal + // /versions/latest/ alias yields 'latest'. Anywhere else (site + // root, unversioned pages) currentVersion stays null so the + // 'latest' alias is NOT surfaced and the browser auto-selects the + // highest v* entry — matching the intent that 'latest' appears in + // the picker only on /versions/latest/. + var currentVersion = null; var m = window.location.pathname.match(/\/versions\/([^\/]+)(?:\/|$)/); if (m) { currentVersion = m[1]; } - // If we're on /versions/latest/, resolve 'latest' to the concrete - // version it points to (matching the `latest` entry's url against - // the versioned entries). Without this resolution, the browser - // auto-selects the first option in the dropdown — which is usually - // the same concrete version 'latest' aliases — and picking that - // option doesn't fire `change`, leaving the user unable to navigate - // away from /versions/latest/ to the equivalent concrete-version - // URL via the picker. - if (currentVersion === 'latest') { - var latestEntry = null; - for (var i = 0; i < versions.length; i++) { - if (versions[i] && versions[i].version === 'latest') { - latestEntry = versions[i]; - break; - } - } - if (latestEntry && latestEntry.url) { - for (var j = 0; j < versions.length; j++) { - var v = versions[j]; - if (v && v.version !== 'latest' && v.url === latestEntry.url) { - currentVersion = v.version; - break; - } - } - } - } - // Build the