Skip to content

Commit

Permalink
fix: event timeline should unmount when hidden and be closed by defau…
Browse files Browse the repository at this point in the history
…lt (#8294)

Fixes 2 bugs:

- The initial state of the event timeline should have `open: false`, not
`true` - Closed by default, unless opened
- The event timeline should unmount when hidden - It should not emit
requests when closed
  • Loading branch information
nunogois authored Sep 27, 2024
1 parent 147984f commit 81840ed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type EventTimelineState = {
};

const defaultState: EventTimelineState = {
open: true,
open: false,
timeSpan: timeSpanOptions[0],
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { Box } from '@mui/material';
import { Box, styled } from '@mui/material';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { EventTimeline } from 'component/events/EventTimeline/EventTimeline';
import { useEffect, useState } from 'react';

interface IMainLayoutEventTimelineProps {
open: boolean;
}

const StyledEventTimelineWrapper = styled(Box)(({ theme }) => ({
backgroundColor: theme.palette.background.paper,
height: '105px',
overflow: 'hidden',
}));

export const MainLayoutEventTimeline = ({
open,
}: IMainLayoutEventTimelineProps) => {
Expand All @@ -16,9 +23,8 @@ export const MainLayoutEventTimeline = ({
}, []);

return (
<Box
<StyledEventTimelineWrapper
sx={{
overflow: 'hidden',
transition: isInitialLoad
? 'none'
: 'max-height 0.3s ease-in-out',
Expand All @@ -31,8 +37,11 @@ export const MainLayoutEventTimeline = ({
backgroundColor: theme.palette.background.paper,
})}
>
<EventTimeline />
<ConditionallyRender
condition={open}
show={<EventTimeline />}
/>
</Box>
</Box>
</StyledEventTimelineWrapper>
);
};

0 comments on commit 81840ed

Please sign in to comment.