Skip to content

Commit b7e7418

Browse files
Merge pull request #2412 from avivtur/avoid-flickring-tree-when-its-off
CNV-55845: Tree view flickering when it should be off
2 parents 21b502f + e5de196 commit b7e7418

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/views/virtualmachines/tree/VirtualMachineTreeView.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { CSSProperties, FC, useEffect, useMemo } from 'react';
1+
import React, { CSSProperties, FC, useMemo } from 'react';
22

33
import { TREE_VIEW } from '@kubevirt-utils/hooks/useFeatures/constants';
44
import { useFeatures } from '@kubevirt-utils/hooks/useFeatures/useFeatures';
@@ -50,12 +50,8 @@ const VirtualMachineTreeView: FC<VirtualMachineTreeViewProps> = ({
5050

5151
const isOpen = useMemo(() => drawerOpen === SHOW, [drawerOpen]);
5252
useHideNamespaceBar();
53-
useEffect(() => {
54-
const drawerPanel = document.getElementById(TREE_VIEW_PANEL_ID);
55-
drawerPanel?.style?.setProperty(PANEL_WIDTH_PROPERTY, drawerWidth);
56-
}, [drawerWidth]);
5753

58-
if (loadError || (!loading && !treeViewEnabled)) return <>{children}</>;
54+
if (loadError || loading || !treeViewEnabled) return <>{children}</>;
5955

6056
const toggleDrawer = () => {
6157
const toggleOpen = !isOpen;
@@ -71,17 +67,21 @@ const VirtualMachineTreeView: FC<VirtualMachineTreeViewProps> = ({
7167
height: getContentScrollableElement().offsetHeight || 0,
7268
};
7369

70+
const widthStyles: any = {
71+
[PANEL_WIDTH_PROPERTY]: drawerWidth,
72+
};
73+
74+
const styles = { ...widthStyles, ...heightStyles } as CSSProperties;
7475
return (
7576
<Drawer isExpanded isInline position="start">
7677
<DrawerContent
7778
panelContent={
7879
<DrawerPanelContent
7980
className="vms-tree-view"
80-
defaultSize={drawerWidth}
8181
id={TREE_VIEW_PANEL_ID}
8282
isResizable={isOpen}
8383
onResize={(_, width: number) => setDrawerWidth(`${String(width)}px`)}
84-
style={heightStyles}
84+
style={styles}
8585
>
8686
<TreeViewContent
8787
isOpen={isOpen}

0 commit comments

Comments
 (0)