1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

fix: event timeline should unmount when hidden and be closed by default (#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
This commit is contained in:
Nuno Góis 2024-09-27 13:11:25 +01:00 committed by GitHub
parent 147984f9d5
commit 81840ed574
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 6 deletions

View File

@ -64,7 +64,7 @@ type EventTimelineState = {
};
const defaultState: EventTimelineState = {
open: true,
open: false,
timeSpan: timeSpanOptions[0],
};

View File

@ -1,4 +1,5 @@
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';
@ -6,6 +7,12 @@ interface IMainLayoutEventTimelineProps {
open: boolean;
}
const StyledEventTimelineWrapper = styled(Box)(({ theme }) => ({
backgroundColor: theme.palette.background.paper,
height: '105px',
overflow: 'hidden',
}));
export const MainLayoutEventTimeline = ({
open,
}: IMainLayoutEventTimelineProps) => {
@ -16,9 +23,8 @@ export const MainLayoutEventTimeline = ({
}, []);
return (
<Box
<StyledEventTimelineWrapper
sx={{
overflow: 'hidden',
transition: isInitialLoad
? 'none'
: 'max-height 0.3s ease-in-out',
@ -31,8 +37,11 @@ export const MainLayoutEventTimeline = ({
backgroundColor: theme.palette.background.paper,
})}
>
<EventTimeline />
<ConditionallyRender
condition={open}
show={<EventTimeline />}
/>
</Box>
</Box>
</StyledEventTimelineWrapper>
);
};