diff --git a/packages/widget/src/components/AppContainer.tsx b/packages/widget/src/components/AppContainer.tsx index 764b66993..fd6f6bb9c 100644 --- a/packages/widget/src/components/AppContainer.tsx +++ b/packages/widget/src/components/AppContainer.tsx @@ -31,7 +31,7 @@ const RelativeContainer = styled(Box)(({ theme }) => ({ const ScrollableContainer = styled(Box)({ // position: 'fixed', - overflowY: 'scroll', + overflowY: 'auto', height: '100%', flex: 1, display: 'flex', diff --git a/packages/widget/src/hooks/useScrollableContainer.ts b/packages/widget/src/hooks/useScrollableContainer.ts index 79b4cb8e4..04a752c0e 100644 --- a/packages/widget/src/hooks/useScrollableContainer.ts +++ b/packages/widget/src/hooks/useScrollableContainer.ts @@ -16,3 +16,17 @@ export const useScrollableContainer = () => { return containerElement; }; + +export const useScrollableOverflowHidden = () => { + useLayoutEffect(() => { + const element = document.getElementById(ElementId.ScrollableContainer); + if (element) { + element.style.overflowY = 'hidden'; + } + return () => { + if (element) { + element.style.overflowY = 'auto'; + } + }; + }, []); +}; diff --git a/packages/widget/src/pages/SelectTokenPage/SelectTokenPage.tsx b/packages/widget/src/pages/SelectTokenPage/SelectTokenPage.tsx index 993b9a983..0e6e78d94 100644 --- a/packages/widget/src/pages/SelectTokenPage/SelectTokenPage.tsx +++ b/packages/widget/src/pages/SelectTokenPage/SelectTokenPage.tsx @@ -1,37 +1,23 @@ import { Box, Container } from '@mui/material'; -import { FC, useLayoutEffect } from 'react'; -import { useTranslation } from 'react-i18next'; +import { FC } from 'react'; import { useNavigate } from 'react-router-dom'; import { TokenList } from '../../components/TokenList'; -import { useContentHeight } from '../../hooks'; +import { useContentHeight, useScrollableOverflowHidden } from '../../hooks'; import { SwapFormDirection } from '../../providers/SwapFormProvider'; -import { ElementId } from '../../utils/elements'; import { ChainSelect } from './ChainSelect'; import { SearchTokenInput } from './SearchTokenInput'; export const SelectTokenPage: FC<{ formType: SwapFormDirection }> = ({ formType, }) => { - const { t } = useTranslation(); const navigate = useNavigate(); + useScrollableOverflowHidden(); const contentHeight = useContentHeight(); const handleTokenClick = () => { navigate(-1); }; - useLayoutEffect(() => { - const element = document.getElementById(ElementId.ScrollableContainer); - if (element) { - element.style.overflowY = 'hidden'; - } - return () => { - if (element) { - element.style.overflowY = 'scroll'; - } - }; - }, []); - return (