diff --git a/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js b/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js index d297ceb14..0c27e31e4 100644 --- a/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js +++ b/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js @@ -334,6 +334,7 @@ if (themeSwitchBtns.length) { "list-group-item list-group-item-action py-1" ); node.setAttribute("href", `${entry.url}${currentFilePath}`); + node.setAttribute("role", "option"); node.appendChild(span); // on click, AJAX calls will check if the linked page exists before @@ -345,21 +346,25 @@ if (themeSwitchBtns.length) { node.dataset["versionName"] = entry.name; node.dataset["version"] = entry.version; - document.querySelector(".version-switcher__menu").append(node); // replace dropdown button text with the preferred display name of // this version, rather than using sphinx's {{ version }} variable. // also highlight the dropdown entry for the currently-viewed // version's entry if ( - entry.version == - "DOCUMENTATION_OPTIONS.version_switcher_version_match" + entry.version == DOCUMENTATION_OPTIONS.theme_switcher_version_match ) { node.classList.add("active"); themeSwitchBtns.forEach((btn) => { - btn.innerText = btn.dataset["activeVersionName"] = entry.name; + btn.innerText = entry.name; + btn.dataset["activeVersionName"] = entry.name; btn.dataset["activeVersion"] = entry.version; }); } + + const menus = document.querySelectorAll(".version-switcher__menu"); + for (let m of menus) { + m.append(node.cloneNode(true)); + } }); }); } diff --git a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/version-switcher.html b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/version-switcher.html index 0085d070a..48f86a978 100644 --- a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/version-switcher.html +++ b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/version-switcher.html @@ -3,11 +3,11 @@