yfm-docs
yfm-docs copied to clipboard
Page does not scroll to the anchor section
Package version
5.0.11
Node version
20.19.2
Platform
Static build
What steps will reproduce the bug?
- Click to the anchor link of a specific section
- Copy link
- Paste link to the browser window
What is the expected behavior?
Page scrolls to the section with id from link.
What do you see instead?
Page does not scroll if I copy anchor link to specific section (i.e. http://localhost:5005/sandbox.html#uspeshnoe-sozdanie-tokena). I tried to curl the page and element with id I copied already was ready in the layout.
Additional information
There is a workaround:
//_assets/scripts
(function () {
window.addEventListener("DOMContentLoaded", function () {
setTimeout(scrollToHash, 100);
});
window.addEventListener("hashchange", function () {
setTimeout(scrollToHash, 50);
});
function scrollToHash() {
if (location.hash) {
const id = decodeURIComponent(location.hash.substring(1));
const el = document.getElementById(id);
if (el) {
el.scrollIntoView({ behavior: "auto", block: "start" });
}
}
}
})();
# .yfm
resources:
script:
- _assets/scripts/fix-anchors.js
hi, this behavior is not reproduced on client 5.6.0 and higher, can you confirm that the problem is still relevant and if so, attach an example of the source code on which you compile the documentation and the prompt does not work there