Skip to content

Commit

Permalink
fix: hide empty scrollbar
Browse files Browse the repository at this point in the history
  • Loading branch information
chybisov committed May 27, 2022
1 parent ee519d2 commit cc2a2fe
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/widget/src/components/AppContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
14 changes: 14 additions & 0 deletions packages/widget/src/hooks/useScrollableContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
};
}, []);
};
20 changes: 3 additions & 17 deletions packages/widget/src/pages/SelectTokenPage/SelectTokenPage.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<Container disableGutters>
<Box pt={1} pb={2} px={3}>
Expand Down

0 comments on commit cc2a2fe

Please sign in to comment.