Skip to content

Commit

Permalink
[Exploratory view] Render content only on expand (#114237)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 authored Oct 12, 2021
1 parent 0b46bb1 commit df971b7
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import React from 'react';
import React, { useEffect, useState } from 'react';
import styled from 'styled-components';
import { i18n } from '@kbn/i18n';
import { EuiFlexItem, EuiFlexGroup, EuiPanel, EuiAccordion, EuiSpacer } from '@elastic/eui';
Expand Down Expand Up @@ -47,6 +47,14 @@ export function Series({ item, isExpanded, toggleExpanded }: Props) {
seriesId: id,
};

const [isExapndedOnce, setIsExapndedOnce] = useState(false);

useEffect(() => {
if (isExpanded) {
setIsExapndedOnce(true);
}
}, [isExpanded]);

return (
<EuiPanel hasBorder={true} data-test-subj={`exploratoryViewSeriesPanel${0}`}>
<StyledAccordion
Expand Down Expand Up @@ -91,7 +99,7 @@ export function Series({ item, isExpanded, toggleExpanded }: Props) {
>
<EuiSpacer size="s" />
<EuiPanel color="subdued">
<ExpandedSeriesRow {...seriesProps} />
{isExapndedOnce && <ExpandedSeriesRow {...seriesProps} />}
</EuiPanel>
</StyledAccordion>
</EuiPanel>
Expand Down

0 comments on commit df971b7

Please sign in to comment.