From f3bfebe99f8b5ea2f29d4bcaf914435fcf31dcd9 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Wed, 3 Jul 2024 13:23:32 -0600 Subject: [PATCH] preserve hash (aka URL fragment) on version change --- src/js/01-nav.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/js/01-nav.js b/src/js/01-nav.js index b54587c0..f29061bc 100644 --- a/src/js/01-nav.js +++ b/src/js/01-nav.js @@ -410,8 +410,9 @@ versionListEl.addEventListener('change', function () { if (versionListEl.dataset.component === page.component) { var selection = versionListEl.options[versionListEl.selectedIndex] - if (selection.dataset.url) { - window.location.href = selection.dataset.url + var selectionUrl = selection.dataset.url + if (selectionUrl) { + window.location.href = selectionUrl + (selectionUrl.startsWith('#') ? '' : window.location.hash) return } }