use scroll into view instead of hash override (#39702)

fixes: #39693

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
This commit is contained in:
Erik Jan de Wit 2025-05-15 14:08:16 +02:00 committed by GitHub
parent 2462c72418
commit 5a992e3f54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -80,10 +80,17 @@ export const ScrollForm = ({
const scrollId = spacesToHyphens(title.toLowerCase());
return (
// note that JumpLinks currently does not work with spaces in the href
<JumpLinksItem
key={title}
href={`#${scrollId}`}
onClick={() => {
const element = document.getElementById(scrollId);
if (element) {
element.scrollIntoView({
behavior: "smooth",
block: "start",
});
}
}}
data-testid={`jump-link-${scrollId}`}
>
{title}