From 93a8d0f157fb707b0e86a5b566f05a10462802b5 Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Wed, 6 Apr 2022 16:44:14 +0300 Subject: [PATCH] Do not render Tooltip and Menu elements until needed (#5168) * Clean up Menu DOM elements Signed-off-by: Alex Andreev * Clean up Tooltip DOM Signed-off-by: Alex Andreev * Do not render Animate when not in need Signed-off-by: Alex Andreev * Update snapshots Signed-off-by: Alex Andreev * clean up and Signed-off-by: Roman Co-authored-by: Roman --- src/renderer/components/animate/animate.tsx | 10 +- .../kube-object-menu.test.tsx.snap | 4 - .../kube-object-status-icon.test.tsx.snap | 216 ------------------ src/renderer/components/menu/menu.tsx | 5 +- src/renderer/components/tooltip/tooltip.tsx | 30 ++- 5 files changed, 31 insertions(+), 234 deletions(-) diff --git a/src/renderer/components/animate/animate.tsx b/src/renderer/components/animate/animate.tsx index f8bbd9b137..df160883fb 100644 --- a/src/renderer/components/animate/animate.tsx +++ b/src/renderer/components/animate/animate.tsx @@ -83,19 +83,23 @@ export class Animate extends React.Component { } render() { + if (!this.isVisible) { + return null; + } + const { name, enterDuration, leaveDuration } = this.props; const contentElem = this.contentElem; - const durations = { + const cssVarsForAnimation = { "--enter-duration": `${enterDuration}ms`, "--leave-duration": `${leaveDuration}ms`, } as React.CSSProperties; return React.cloneElement(contentElem, { className: cssNames("Animate", name, contentElem.props.className, this.statusClassName), - children: this.isVisible ? contentElem.props.children : null, + children: contentElem.props.children, style: { ...contentElem.props.style, - ...durations, + ...cssVarsForAnimation, }, }); } diff --git a/src/renderer/components/kube-object-menu/__snapshots__/kube-object-menu.test.tsx.snap b/src/renderer/components/kube-object-menu/__snapshots__/kube-object-menu.test.tsx.snap index 0d1d591668..b0200f73d5 100644 --- a/src/renderer/components/kube-object-menu/__snapshots__/kube-object-menu.test.tsx.snap +++ b/src/renderer/components/kube-object-menu/__snapshots__/kube-object-menu.test.tsx.snap @@ -37,10 +37,6 @@ exports[`kube-object-menu given kube object renders 1`] = ` -