@@ -28,7 +28,6 @@ interface NodeStructureProps {
2828 nodeId : string ;
2929 className ?: string ;
3030 additionalNodesInfo ?: any ;
31- scrollContainer : Element | null ;
3231}
3332
3433const autofetcher = new AutoFetcher ( ) ;
@@ -40,9 +39,7 @@ function NodeStructure(props: NodeStructureProps) {
4039
4140 const loadingStructure = useSelector ( ( state : any ) => state . node . loadingStructure ) ;
4241 const wasLoadedStructure = useSelector ( ( state : any ) => state . node . wasLoadedStructure ) ;
43- const nodeData = useSelector (
44- ( state : any ) => state . node ?. data ?. SystemStateInfo ?. [ 0 ]
45- ) ;
42+ const nodeData = useSelector ( ( state : any ) => state . node ?. data ?. SystemStateInfo ?. [ 0 ] ) ;
4643
4744 const nodeHref = useMemo ( ( ) => {
4845 return props . additionalNodesInfo ?. getNodeRef
@@ -55,13 +52,15 @@ function NodeStructure(props: NodeStructureProps) {
5552 true ,
5653 ) . query ;
5754
55+ const scrollContainerRef = useRef < HTMLDivElement > ( null ) ;
56+ const scrollContainer = scrollContainerRef . current ;
57+
5858 const isReady = useRef ( false ) ;
5959
6060 const scrolled = useRef ( false ) ;
6161
6262 useEffect ( ( ) => {
6363 return ( ) => {
64- const { scrollContainer} = props ;
6564 if ( scrollContainer ) {
6665 scrollContainer . scrollTo ( {
6766 behavior : 'smooth' ,
@@ -84,13 +83,12 @@ function NodeStructure(props: NodeStructureProps) {
8483 } , [ props . nodeId , dispatch ] ) ;
8584
8685 useEffect ( ( ) => {
87- if ( ! _ . isEmpty ( nodeStructure ) && props . scrollContainer ) {
86+ if ( ! _ . isEmpty ( nodeStructure ) && scrollContainer ) {
8887 isReady . current = true ;
8988 }
90- } , [ nodeStructure , props . scrollContainer ] ) ;
89+ } , [ nodeStructure ] ) ;
9190
9291 useEffect ( ( ) => {
93- const { scrollContainer} = props ;
9492 if ( isReady . current && ! scrolled . current && scrollContainer ) {
9593 const element = document . getElementById (
9694 generateId ( { type : 'pdisk' , id : pdiskIdFromUrl as string } ) ,
@@ -105,20 +103,20 @@ function NodeStructure(props: NodeStructureProps) {
105103 const order = vDisk ?. order ;
106104
107105 if ( dataTable ) {
108- scrollToVdisk += ( dataTable as HTMLElement ) . offsetTop + 40 * ( order + 1 ) ;
106+ scrollToVdisk += ( dataTable as HTMLElement ) . offsetTop + 40 * order ;
109107 }
110108 }
111109
112110 if ( element ) {
113111 scrollContainer . scrollTo ( {
114112 behavior : 'smooth' ,
115113 // should subtract 20 to avoid sticking the element to tabs
116- top : scrollToVdisk ? scrollToVdisk : element . offsetTop - 20 ,
114+ top : scrollToVdisk ? scrollToVdisk : element . offsetTop ,
117115 } ) ;
118116 scrolled . current = true ;
119117 }
120118 }
121- } , [ nodeStructure , props . scrollContainer , pdiskIdFromUrl , vdiskIdFromUrl ] ) ;
119+ } , [ nodeStructure , pdiskIdFromUrl , vdiskIdFromUrl ] ) ;
122120
123121 const renderStub = ( ) => {
124122 return 'There is no information about node structure.' ;
@@ -147,7 +145,11 @@ function NodeStructure(props: NodeStructureProps) {
147145 return renderStructure ( ) ;
148146 } ;
149147
150- return < div className = { b ( null , props . className ) } > { renderContent ( ) } </ div > ;
148+ return (
149+ < div className = { b ( ) } ref = { scrollContainerRef } >
150+ < div className = { props . className } > { renderContent ( ) } </ div >
151+ </ div >
152+ ) ;
151153}
152154
153155export default NodeStructure ;
0 commit comments