From ba1b60d538259799718f38c90e9b6a78f0b66637 Mon Sep 17 00:00:00 2001 From: Jiang Feng Date: Sun, 27 Apr 2025 16:15:49 +0800 Subject: [PATCH] feat: set active tab to activities on research change --- web/src/app/_components/research-block.tsx | 5 +++++ web/src/app/_components/scroll-container.tsx | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/web/src/app/_components/research-block.tsx b/web/src/app/_components/research-block.tsx index fb3507c..1f55536 100644 --- a/web/src/app/_components/research-block.tsx +++ b/web/src/app/_components/research-block.tsx @@ -63,6 +63,11 @@ export function ResearchBlock({ }, 1000); }, [reportId]); + // When the research id changes, set the active tab to activities + useEffect(() => { + setActiveTab("activities"); + }, [researchId]); + return (
diff --git a/web/src/app/_components/scroll-container.tsx b/web/src/app/_components/scroll-container.tsx index a3a546e..ecc7d01 100644 --- a/web/src/app/_components/scroll-container.tsx +++ b/web/src/app/_components/scroll-container.tsx @@ -1,7 +1,7 @@ // Copyright (c) 2025 Bytedance Ltd. and/or its affiliates // SPDX-License-Identifier: MIT -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; import { useStickToBottom } from "use-stick-to-bottom"; import { ScrollArea } from "~/components/ui/scroll-area"; @@ -23,11 +23,18 @@ export function ScrollContainer({ const { scrollRef, contentRef } = useStickToBottom({ initial: "instant", }); + const tempScrollRef = useRef(null); + const tempContentRef = useRef(null); useEffect(() => { if (!autoScrollToBottom) { + tempScrollRef.current = scrollRef.current; + tempContentRef.current = contentRef.current; scrollRef.current = null; contentRef.current = null; + } else if (tempScrollRef.current && tempContentRef.current) { + scrollRef.current = tempScrollRef.current; + contentRef.current = tempContentRef.current; } }, [autoScrollToBottom, contentRef, scrollRef]);