fix(curriculum): fix anchors with hash within iframe to scroll to target element (#59508)

This commit is contained in:
dennmar
2025-04-03 11:41:16 -07:00
committed by GitHub
parent 9d9f65ce45
commit 175c46c43e

View File

@@ -130,6 +130,15 @@ const createHeader = (id = mainPreviewId) =>
if (!href || href[0] !== '#' && !href.match(/^https?:\\/\\//)) {
e.preventDefault();
}
else if (href.match(/^#.+/)) {
e.preventDefault();
const scrollId = href.substring(1);
const scrollElem = document.getElementById(scrollId);
if (scrollElem) {
scrollElem.scrollIntoView();
}
}
}
}, false);
document.addEventListener('submit', function(e) {