mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
23 lines
678 B
TypeScript
23 lines
678 B
TypeScript
"use client";
|
|
|
|
import { useEffect } from "react";
|
|
import { usePathname } from "next/navigation";
|
|
|
|
/**
|
|
* Resets scroll position of the parent scroll container when navigating to a new page.
|
|
* Fixes issue where scroll position persists when using collapsed TOC navigation.
|
|
*/
|
|
export function ScrollReset() {
|
|
const pathname = usePathname();
|
|
|
|
useEffect(() => {
|
|
// Find the scroll container (docs-content-wrapper)
|
|
const scrollContainer = document.querySelector(".docs-content-wrapper");
|
|
if (scrollContainer) {
|
|
scrollContainer.scrollTop = 0;
|
|
}
|
|
}, [pathname]); // Run whenever pathname changes
|
|
|
|
return null; // This component doesn't render anything
|
|
}
|