From 56f476649c7ae52dd44c0542a106fa5b80e956a4 Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Sun, 1 Feb 2026 10:52:45 +0000 Subject: [PATCH] scroll --- .../page-history/components/history-modal-body.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/client/src/features/page-history/components/history-modal-body.tsx b/apps/client/src/features/page-history/components/history-modal-body.tsx index 12e1ee05..7d5b3a24 100644 --- a/apps/client/src/features/page-history/components/history-modal-body.tsx +++ b/apps/client/src/features/page-history/components/history-modal-body.tsx @@ -9,7 +9,7 @@ import { } from "@mantine/core"; import HistoryList from "@/features/page-history/components/history-list"; import classes from "./history.module.css"; -import { useAtom, useSetAtom } from "jotai"; +import { useAtom } from "jotai"; import { activeHistoryIdAtom, activeHistoryPrevIdAtom, @@ -30,8 +30,7 @@ export default function HistoryModalBody({ pageId }: Props) { activeHistoryPrevIdAtom, ); const [highlightChanges, setHighlightChanges] = useAtom(highlightChangesAtom); - const [diffCounts] = useAtom(diffCountsAtom); - const [, setDiffCounts] = useAtom(diffCountsAtom); + const [diffCounts, setDiffCounts] = useAtom(diffCountsAtom); const [currentChangeIndex, setCurrentChangeIndex] = useState(0); const scrollViewportRef = useRef(null); @@ -44,8 +43,13 @@ export default function HistoryModalBody({ pageId }: Props) { }, [pageId]); useEffect(() => { - setCurrentChangeIndex(0); - }, [activeHistoryId]); + if (diffCounts && diffCounts.total > 0) { + setCurrentChangeIndex(1); + requestAnimationFrame(() => scrollToChangeIndex(1)); + } else { + setCurrentChangeIndex(0); + } + }, [diffCounts]); const scrollToChangeIndex = (index: number) => { const viewport = scrollViewportRef.current;