1
- import React , { CSSProperties , FC , useEffect , useMemo } from 'react' ;
1
+ import React , { CSSProperties , FC , useMemo } from 'react' ;
2
2
3
3
import { TREE_VIEW } from '@kubevirt-utils/hooks/useFeatures/constants' ;
4
4
import { useFeatures } from '@kubevirt-utils/hooks/useFeatures/useFeatures' ;
@@ -50,12 +50,8 @@ const VirtualMachineTreeView: FC<VirtualMachineTreeViewProps> = ({
50
50
51
51
const isOpen = useMemo ( ( ) => drawerOpen === SHOW , [ drawerOpen ] ) ;
52
52
useHideNamespaceBar ( ) ;
53
- useEffect ( ( ) => {
54
- const drawerPanel = document . getElementById ( TREE_VIEW_PANEL_ID ) ;
55
- drawerPanel ?. style ?. setProperty ( PANEL_WIDTH_PROPERTY , drawerWidth ) ;
56
- } , [ drawerWidth ] ) ;
57
53
58
- if ( loadError || ( ! loading && ! treeViewEnabled ) ) return < > { children } </ > ;
54
+ if ( loadError || loading || ! treeViewEnabled ) return < > { children } </ > ;
59
55
60
56
const toggleDrawer = ( ) => {
61
57
const toggleOpen = ! isOpen ;
@@ -71,17 +67,21 @@ const VirtualMachineTreeView: FC<VirtualMachineTreeViewProps> = ({
71
67
height : getContentScrollableElement ( ) . offsetHeight || 0 ,
72
68
} ;
73
69
70
+ const widthStyles : any = {
71
+ [ PANEL_WIDTH_PROPERTY ] : drawerWidth ,
72
+ } ;
73
+
74
+ const styles = { ...widthStyles , ...heightStyles } as CSSProperties ;
74
75
return (
75
76
< Drawer isExpanded isInline position = "start" >
76
77
< DrawerContent
77
78
panelContent = {
78
79
< DrawerPanelContent
79
80
className = "vms-tree-view"
80
- defaultSize = { drawerWidth }
81
81
id = { TREE_VIEW_PANEL_ID }
82
82
isResizable = { isOpen }
83
83
onResize = { ( _ , width : number ) => setDrawerWidth ( `${ String ( width ) } px` ) }
84
- style = { heightStyles }
84
+ style = { styles }
85
85
>
86
86
< TreeViewContent
87
87
isOpen = { isOpen }
0 commit comments