From bbf95d9f36e84663ff06eef4062edb14b64aee9c Mon Sep 17 00:00:00 2001 From: Lucas Leblanc <44496264+Dedelweiss@users.noreply.github.com> Date: Mon, 12 Jun 2023 16:28:40 +0200 Subject: [PATCH] Fix: Correct the navigation to anchor (#17910) The browser compatibility of [`location.hash`](https://developer.mozilla.org/en-US/docs/Web/API/Location/hash) seems to be out of date. That's why in this fix, I suggest using [`history.replaceState`](https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState). ## Before: https://github.com/lampepfl/dotty/assets/44496264/a1399b0b-e4e8-4754-b146-661b59a01824 ## After: https://github.com/lampepfl/dotty/assets/44496264/22f38852-0cc5-48eb-a6e7-699f11628401 Fixes: #17182 [Cherry-picked 7694985b7ade95fd5a970a5d659439dc44f471c5] --- scaladoc/resources/dotty_res/scripts/ux.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scaladoc/resources/dotty_res/scripts/ux.js b/scaladoc/resources/dotty_res/scripts/ux.js index 0ead006af84d..dd6e798f17a5 100644 --- a/scaladoc/resources/dotty_res/scripts/ux.js +++ b/scaladoc/resources/dotty_res/scripts/ux.js @@ -285,7 +285,7 @@ document getTocListElement(id).parentElement.classList.toggle("active"); } if (lastEntry.isIntersecting) { - window.location.hash = ""; + history.replaceState(history.state, "", window.location.pathname + window.location.search); removeAllHighlights(); const id = getIdOfElement(lastEntry);