From d3c25422d4df5eb1e270513041423a06fa43c7fb Mon Sep 17 00:00:00 2001 From: trafficlunar Date: Sat, 8 Feb 2025 13:40:37 +0000 Subject: [PATCH] fix: automatically scroll div down in history panel --- src/components/tool-settings/History.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/tool-settings/History.tsx b/src/components/tool-settings/History.tsx index 49e4e00..5079cbb 100644 --- a/src/components/tool-settings/History.tsx +++ b/src/components/tool-settings/History.tsx @@ -16,9 +16,15 @@ const iconMap = { function History() { const { history, currentIndex, jumpTo } = useContext(HistoryContext); + const divRef = useRef(null); + + useEffect(() => { + divRef.current?.scrollIntoView(false); + }, [history]); + return ( -
+
{history.map(({ name }, index) => { const IconComponent = iconMap[name as keyof typeof iconMap];