diff --git a/packages/widget/src/pages/SelectTokenPage/SelectTokenPage.tsx b/packages/widget/src/pages/SelectTokenPage/SelectTokenPage.tsx index 0e6e78d94..00ff171ca 100644 --- a/packages/widget/src/pages/SelectTokenPage/SelectTokenPage.tsx +++ b/packages/widget/src/pages/SelectTokenPage/SelectTokenPage.tsx @@ -1,5 +1,5 @@ import { Box, Container } from '@mui/material'; -import { FC } from 'react'; +import { FC, useLayoutEffect, useRef, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { TokenList } from '../../components/TokenList'; import { useContentHeight, useScrollableOverflowHidden } from '../../hooks'; @@ -10,24 +10,30 @@ import { SearchTokenInput } from './SearchTokenInput'; export const SelectTokenPage: FC<{ formType: SwapFormDirection }> = ({ formType, }) => { - const navigate = useNavigate(); useScrollableOverflowHidden(); + const navigate = useNavigate(); + const headerRef = useRef(null); const contentHeight = useContentHeight(); + const [headerHeight, setHeaderHeight] = useState(0); const handleTokenClick = () => { navigate(-1); }; + useLayoutEffect(() => { + setHeaderHeight(contentHeight - (headerRef.current?.offsetHeight ?? 0)); + }, [contentHeight]); + return ( - +