From 71d306cd8f32955a592ceda899c4c7fe3f9c9805 Mon Sep 17 00:00:00 2001 From: Angela Chuang Date: Thu, 31 Dec 2020 06:11:53 +0800 Subject: [PATCH] caculate dynamic height --- .../event_details/event_details.tsx | 1 - .../timeline/expandable_event/index.tsx | 32 +++++++++++-------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/x-pack/plugins/security_solution/public/common/components/event_details/event_details.tsx b/x-pack/plugins/security_solution/public/common/components/event_details/event_details.tsx index a174b5b514049..af64b90a4d4ed 100644 --- a/x-pack/plugins/security_solution/public/common/components/event_details/event_details.tsx +++ b/x-pack/plugins/security_solution/public/common/components/event_details/event_details.tsx @@ -51,7 +51,6 @@ const StyledEuiTabbedContent = styled(EuiTabbedContent)` const TabContentWrapper = styled.div` height: 100%; position: relative; - margin-bottom: 48px; `; const EventDetailsComponent: React.FC = ({ diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/expandable_event/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/expandable_event/index.tsx index 51bb034a9e054..65db48001e03b 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/expandable_event/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/expandable_event/index.tsx @@ -17,7 +17,7 @@ import { EuiFlexGroup, EuiFlexItem, } from '@elastic/eui'; -import React, { useMemo, useState } from 'react'; +import React, { useMemo, useRef, useState } from 'react'; import styled from 'styled-components'; import { TimelineExpandedEventType, TimelineTabs } from '../../../../../common/types/timeline'; @@ -38,6 +38,7 @@ interface Props { event: TimelineExpandedEventType; isAlert: boolean; loading: boolean; + messageHeight?: number; timelineTabType: TimelineTabs | 'flyout'; timelineId: string; } @@ -55,11 +56,10 @@ const StyledEuiFlexGroup = styled(EuiFlexGroup)` const StyledFlexGroup = styled(EuiFlexGroup)` height: 100%; `; - -const StyledEuiFlexItem = styled(EuiFlexItem)` - max-height: 100%; - padding-bottom: 48px; - box-sizing: border-box; +const TabListHeight = 48; +const StyledEuiFlexItem = styled(EuiFlexItem)<{ $tabListHeight?: number; $messageHeight?: number }>` + ${({ $tabListHeight = TabListHeight, $messageHeight = 0 }) => + `max-height: calc(100% - ${$tabListHeight}px - ${$messageHeight}px);`} `; export const ExpandableEventTitle = React.memo( @@ -100,6 +100,8 @@ export const ExpandableEvent = React.memo( return null; }, [detailsData]); + const messageRef = useRef(null); + if (!event.eventId) { return {i18n.EVENT_DETAILS_PLACEHOLDER}; } @@ -112,16 +114,18 @@ export const ExpandableEvent = React.memo( {message && ( - - {i18n.MESSAGE} - - - - - +
+ + {i18n.MESSAGE} + + + + + +
)} - +