diff --git a/apify-docs-theme/static/js/custom.js b/apify-docs-theme/static/js/custom.js index e9a7ece756..38988521dc 100644 --- a/apify-docs-theme/static/js/custom.js +++ b/apify-docs-theme/static/js/custom.js @@ -32,3 +32,45 @@ // load(); // } // }, 500); + +let lastKnownScrollHash = ''; + +// handles automatic scrolling of the API reference sidebar (redoc) +function scrollSidebarItemIntoView() { + const hash = window.location.hash.substring(1); + + if (hash !== lastKnownScrollHash) { + const $li = document.querySelector(`li[data-item-id="${hash}"]`); + + if (!$li) { + return; + } + + // not visible, click on the parent