@@ -495,15 +495,21 @@ const getFocusedNodeData = (
495495}
496496
497497const DisplayStructureTree : s . Component = ( ) => {
498- const [ containerScroll , setContainerScroll ] = s . createSignal ( { top : 0 , height : 0 } )
498+
499+ const [ containerScroll , setContainerScroll ] = s . createSignal ( {
500+ top : 0 ,
501+ height : 0 ,
502+ } , {
503+ equals : ( a , b ) => a . top === b . top && a . height === b . height
504+ } )
499505
500506 const remSize = useRemSize ( )
501- const getContainerTopMargin = ( ) : number => remSize ( ) * v_margin_in_rem
502- const getRowHeight = ( ) : number => remSize ( ) * row_height_in_rem
507+ const getContainerTopMargin = ( ) => remSize ( ) * v_margin_in_rem
508+ const getRowHeight = ( ) => remSize ( ) * row_height_in_rem
503509
504510 const updateScrollData = ( el : HTMLElement ) : void => {
505511 setContainerScroll ( {
506- top : Math . max ( el . scrollTop - getContainerTopMargin ( ) , 0 ) ,
512+ top : Math . max ( el . scrollTop - getContainerTopMargin ( ) , 0 ) ,
507513 height : el . clientHeight ,
508514 } )
509515 }
@@ -621,16 +627,14 @@ const DisplayStructureTree: s.Component = () => {
621627 } )
622628
623629 // Seep the inspected or central node in view when the list is changing
624- s . createEffect (
625- defer ( collapsedList , ( ) => {
626- if ( ! lastFocusedNodeData ) return
627- const [ nodeId , lastPosition ] = lastFocusedNodeData
628- const index = getNodeIndexById ( nodeId )
629- if ( index === - 1 ) return
630- const move = index - virtual ( ) . start - lastPosition
631- if ( move !== 0 ) container . scrollTop += move * getRowHeight ( )
632- } ) ,
633- )
630+ s . createEffect ( defer ( collapsedList , ( ) => {
631+ if ( ! lastFocusedNodeData ) return
632+ const [ nodeId , lastPosition ] = lastFocusedNodeData
633+ const index = getNodeIndexById ( nodeId )
634+ if ( index === - 1 ) return
635+ const move = index - virtual ( ) . start - lastPosition
636+ if ( move !== 0 ) container . scrollTop += move * getRowHeight ( )
637+ } ) )
634638
635639 // Scroll to selected node when it changes
636640 // listen to inspected ID, instead of node, because node reference can change
@@ -752,8 +756,17 @@ const DisplayStructureTree: s.Component = () => {
752756 < ui . Scrollable
753757 ref = { el => {
754758 container = el
755- setTimeout ( ( ) => updateScrollData ( el ) )
756- createResizeObserver ( el , ( ) => updateScrollData ( el ) )
759+ createResizeObserver ( el , ( ) => {
760+ /*
761+ Update data in timeout, after the ResizeObserver callback
762+ To prevent this error:
763+ > ResizeObserver loop completed with undelivered notifications
764+ As changing scroll data can then change el.scrollTop
765+ */
766+ setTimeout ( ( ) => {
767+ updateScrollData ( el )
768+ } )
769+ } )
757770 } }
758771 onScroll = { e => updateScrollData ( e . currentTarget ) }
759772 >
0 commit comments