diff --git a/packages/ui/app/src/commons/AbsolutelyPositionedAnchor.tsx b/packages/ui/app/src/commons/AbsolutelyPositionedAnchor.tsx index ba872465d8..de1f6a2497 100644 --- a/packages/ui/app/src/commons/AbsolutelyPositionedAnchor.tsx +++ b/packages/ui/app/src/commons/AbsolutelyPositionedAnchor.tsx @@ -61,7 +61,7 @@ export const AbsolutelyPositionedAnchor: React.FC; } -const smoothScrollIntoView = debounce( - (node: HTMLElement) => { - node.scrollIntoView({ behavior: "smooth" }); - }, - 100, - { leading: true, trailing: false } -); - export const NavigationContextProvider: React.FC = ({ resolvedPath, children, @@ -69,20 +61,14 @@ export const NavigationContextProvider: React.FC { + const navigateToRoute = useRef((route: string, _disableSmooth = false) => { const [routeWithoutAnchor, _anchor] = route.split("#"); if (!userIsScrolling.current && routeWithoutAnchor != null) { // fallback to "routeWithoutAnchor" if anchor is not detected (otherwise API reference will scroll to top) const node = getRouteNode(route) ?? getRouteNode(routeWithoutAnchor); - if (node != null) { - if (disableSmooth) { - node.scrollIntoView({ - behavior: "auto", - }); - } else { - smoothScrollIntoView(node); - } - } + node?.scrollIntoView({ + behavior: "auto", + }); } justNavigatedTo.current = route; });