Skip to content

Commit

Permalink
Merge pull request #121 from zetkin/issue-117/overflow-fix
Browse files Browse the repository at this point in the history
Remove overflow hack from MessageList
  • Loading branch information
WULCAN authored Jul 27, 2024
2 parents d08fa80 + 49a21bf commit 1ac8bbf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
14 changes: 6 additions & 8 deletions webapp/src/components/Main.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import Box from '@mui/material/Box';
import { FC, ReactNode } from 'react';

Expand All @@ -11,12 +9,12 @@ const Main: FC<MainProps> = ({ children }) => {
return (
<Box
component="main"
sx={{
display: 'flex',
flex: 1,
flexDirection: 'column',
marginTop: 6,
}}
display="flex"
flex={1}
flexDirection="column"
height="calc(100dvh - var(--Header-height))"
marginTop="var(--Header-height)"
overflow="hidden"
>
{children}
</Box>
Expand Down
12 changes: 8 additions & 4 deletions webapp/src/components/MessageList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import ListItem from '@mui/material/ListItem';
import { ListItem } from '@mui/material';
import { FC, useCallback, useEffect, useState } from 'react';
import { FixedSizeList, ListChildComponentProps } from 'react-window';
import { useMediaQuery, useTheme } from '@mui/material';
Expand Down Expand Up @@ -28,12 +28,16 @@ const MessageList: FC<MessageListProps> = ({
const layout = lg ? 'grid' : 'linear';

const onResize = useCallback(() => {
setHeight(window.innerHeight);
const headerHeight = parseInt(
getComputedStyle(document.documentElement).getPropertyValue(
'--Header-height',
),
);
setHeight(window.innerHeight - headerHeight);
}, []);

useEffect(() => {
if (typeof window === 'object') {
document.body.style.overflow = 'hidden';
onResize();
window.addEventListener('resize', onResize);
return () => window.removeEventListener('resize', onResize);
Expand Down Expand Up @@ -63,7 +67,7 @@ const MessageList: FC<MessageListProps> = ({
<>
{height && (
<FixedSizeList
height={window.innerHeight}
height={height}
itemCount={messages.length}
itemSize={messageFormHeight(layout)}
overscanCount={5}
Expand Down

0 comments on commit 1ac8bbf

Please sign in to comment.