From 4e00920e15709c049af6e9b5d25c2d090b7f295b Mon Sep 17 00:00:00 2001 From: Maciej Bodek Date: Thu, 19 Oct 2023 09:47:51 +0200 Subject: [PATCH] fix: schema list: shadow initial state --- packages/web-console/src/scenes/Schema/index.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/web-console/src/scenes/Schema/index.tsx b/packages/web-console/src/scenes/Schema/index.tsx index a93c3e068..9f7d4975b 100644 --- a/packages/web-console/src/scenes/Schema/index.tsx +++ b/packages/web-console/src/scenes/Schema/index.tsx @@ -106,7 +106,7 @@ const Schema = ({ const [isScrolling, setIsScrolling] = useState(false) const { readOnly } = useSelector(selectors.console.getConfig) const dispatch = useDispatch() - const [scrollAtTop, setScrollAtTop] = useState(false) + const [scrollAtTop, setScrollAtTop] = useState(true) const scrollerRef = useRef(null) const handleChange = useCallback((name: string) => { @@ -187,8 +187,10 @@ const Schema = ({ }, [errorRef, fetchTables]) useEffect(() => { - setScrollAtTop(scrollerRef.current?.scrollTop === 0) - }, [isScrolling]) + if (tables && tables?.length >= VIRTUAL_SCROLL_THRESHOLD) { + setScrollAtTop(scrollerRef.current?.scrollTop === 0) + } + }, [isScrolling, tables]) return (