@@ -390,31 +390,31 @@ export function NodeContent<CONTENT_PROPS = any>({
390390 flowVersionCheck === "legacy" ? ( [ ] as NodeContentHandleLegacyProps [ ] ) : ( [ ] as NodeContentHandleNextProps [ ] ) ;
391391
392392 const saveOriginalSize = ( ) => {
393+ const currentClassNames = nodeContentRef . current . classList ;
394+ if ( currentClassNames . contains ( "was-resized" ) && ! width && ! height ) {
395+ currentClassNames . remove ( "was-resized" ) ;
396+ }
393397 originalSize . current . width = nodeContentRef . current . offsetWidth as number ;
394398 originalSize . current . height = nodeContentRef . current . offsetHeight as number ;
395399 }
396400
397401 React . useEffect ( ( ) => {
398- if ( nodeContentRef . current && ! ( originalSize . current . width || originalSize . current . height ) ) {
402+ if ( nodeContentRef . current && ( ! ( originalSize . current . width || originalSize . current . height ) || ! ( width || height ) ) ) {
399403 saveOriginalSize ( ) ;
400404 }
401- } , [ ! ! nodeContentRef . current , ! ( originalSize . current . width || originalSize . current . height ) ] )
405+ } , [ ! ! nodeContentRef . current , ! ( originalSize . current . width || originalSize . current . height ) , ! ( width || height ) ] )
402406
403407 // Update width and height when node dimensions parameters has changed
404408 React . useEffect ( ( ) => {
405409 const updateWidth = nodeDimensions ?. width ? validateWidth ( nodeDimensions ?. width ) : undefined ;
406410 const updateHeight = nodeDimensions ?. height ? validateHeight ( nodeDimensions ?. height ) : undefined ;
407411 setWidth ( updateWidth ) ;
408412 setHeight ( updateHeight ) ;
409- if ( ! nodeDimensions ?. width && ! nodeDimensions ?. height ) {
410- // provoke new measuring if no dimensions are set
411- saveOriginalSize ( ) ;
412- }
413413 } , [ nodeDimensions ] ) ;
414414
415415 const isResizingActive = React . useCallback ( ( ) : boolean => {
416416 const currentClassNames = nodeContentRef . current . classList ;
417- return resizeDirections . right === currentClassNames . contains ( "is-resizable-horizontal" ) &&
417+ return resizeDirections . right === currentClassNames . contains ( "is-resizable-horizontal" ) ||
418418 resizeDirections . bottom === currentClassNames . contains ( "is-resizable-vertical" ) ;
419419 } , [ ] )
420420
@@ -439,17 +439,17 @@ export function NodeContent<CONTENT_PROPS = any>({
439439
440440 if ( isResizable && ! resizingActive ) {
441441 if ( currentClassNames . contains ( "is-resizable-horizontal" ) ) {
442- nodeContentRef . current . classList . remove ( "is-resizable-horizontal" ) ;
442+ currentClassNames . remove ( "is-resizable-horizontal" ) ;
443443 }
444444 if ( currentClassNames . contains ( "is-resizable-vertical" ) ) {
445- nodeContentRef . current . classList . remove ( "is-resizable-vertical" ) ;
445+ currentClassNames . remove ( "is-resizable-vertical" ) ;
446446 }
447-
447+
448448 if ( resizeDirections . right ) {
449- nodeContentRef . current . classList . add ( "is-resizable-horizontal" ) ;
449+ currentClassNames . add ( "is-resizable-horizontal" ) ;
450450 }
451451 if ( resizeDirections . bottom ) {
452- nodeContentRef . current . classList . add ( "is-resizable-vertical" ) ;
452+ currentClassNames . add ( "is-resizable-vertical" ) ;
453453 }
454454 }
455455 } ) ; // need to be done everytime a property is changed and the element is re-rendered, otherwise the resizing class is lost
@@ -524,8 +524,8 @@ export function NodeContent<CONTENT_PROPS = any>({
524524 ? {
525525 width,
526526 height,
527- maxWidth : resizeMaxDimensions ?. width ?? undefined ,
528- maxHeight : resizeMaxDimensions ?. height ?? undefined ,
527+ maxWidth : resizeDirections . right ? resizeMaxDimensions ?. width ?? undefined : undefined ,
528+ maxHeight : resizeDirections . bottom ? resizeMaxDimensions ?. height ?? undefined : undefined ,
529529 }
530530 : { } ;
531531
@@ -705,6 +705,10 @@ export function NodeContent<CONTENT_PROPS = any>({
705705 const nextHeight = resizeDirections . bottom
706706 ? ( height ?? originalSize . current . height ?? 0 ) + d . height
707707 : undefined ;
708+ if ( nextWidth || nextHeight ) {
709+ const currentClassNames = nodeContentRef . current . classList ;
710+ currentClassNames . add ( "was-resized" ) ;
711+ }
708712 if ( nextWidth ) {
709713 nodeContentRef . current . style . width = `${ nextWidth } px` ;
710714 }
0 commit comments