Skip to content

Commit

Permalink
fix: schema list: shadow initial state
Browse files Browse the repository at this point in the history
  • Loading branch information
insmac committed Oct 19, 2023
1 parent 51608fa commit 4e00920
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/web-console/src/scenes/Schema/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLDivElement | null>(null)

const handleChange = useCallback((name: string) => {
Expand Down Expand Up @@ -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 (
<Wrapper ref={innerRef} {...rest}>
Expand Down

0 comments on commit 4e00920

Please sign in to comment.