@ -100,36 +100,27 @@ export function BaseNode({
const panelEl = settingsPanelRef . current ;
const panelEl = settingsPanelRef . current ;
if ( ! panelEl ) return ;
if ( ! panelEl ) return ;
let rafId : number | null = null ;
const observer = new ResizeObserver ( ( entries ) = > {
const observer = new ResizeObserver ( ( entries ) = > {
if ( rafId !== null ) cancelAnimationFrame ( rafId ) ;
for ( const entry of entries ) {
rafId = requestAnimationFrame ( ( ) = > {
const newPanelHeight = entry . contentRect . height ;
rafId = null ;
if ( newPanelHeight === 0 ) continue ;
for ( const entry of entries ) {
const delta = newPanelHeight - trackedSettingsHeightRef . current ;
const newPanelHeight = entry . contentRect . height ;
if ( Math . abs ( delta ) < 2 ) continue ; // Ignore sub-pixel changes
if ( newPanelHeight === 0 ) continue ;
const delta = newPanelHeight - trackedSettingsHeightRef . current ;
trackedSettingsHeightRef . current = newPanelHeight ;
if ( Math . abs ( delta ) < 2 ) continue ; // Ignore sub-pixel changes
setNodes ( ( nodes ) = >
nodes . map ( ( node ) = > {
trackedSettingsHeightRef . current = newPanelHeight ;
if ( node . id !== id ) return node ;
setNodes ( ( nodes ) = >
const currentHeight = getNodeDimension ( node , "height" ) ;
nodes . map ( ( node ) = > {
const newHeight = Math . max ( minHeight , currentHeight + delta ) ;
if ( node . id !== id ) return node ;
return applyNodeDimensions ( node , getNodeDimension ( node , "width" ) , newHeight ) ;
const currentHeight = getNodeDimension ( node , "height" ) ;
} )
const newHeight = Math . max ( minHeight , currentHeight + delta ) ;
) ;
return applyNodeDimensions ( node , getNodeDimension ( node , "width" ) , newHeight ) ;
}
} )
) ;
}
} ) ;
} ) ;
} ) ;
observer . observe ( panelEl ) ;
observer . observe ( panelEl ) ;
return ( ) = > {
return ( ) = > observer . disconnect ( ) ;
if ( rafId !== null ) cancelAnimationFrame ( rafId ) ;
observer . disconnect ( ) ;
} ;
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-hooks/exhaustive-deps
} , [ settingsExpanded , settingsPanel ] ) ;
} , [ settingsExpanded , settingsPanel ] ) ;