Skip to content

Commit 90bddad

Browse files
committed
fix node size reset for the y-axis
1 parent 7bf8b70 commit 90bddad

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/extensions/react-flow/nodes/NodeContent.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,10 @@ 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
}
@@ -435,17 +439,17 @@ export function NodeContent<CONTENT_PROPS = any>({
435439

436440
if (isResizable && !resizingActive) {
437441
if (currentClassNames.contains("is-resizable-horizontal")) {
438-
nodeContentRef.current.classList.remove("is-resizable-horizontal");
442+
currentClassNames.remove("is-resizable-horizontal");
439443
}
440444
if (currentClassNames.contains("is-resizable-vertical")) {
441-
nodeContentRef.current.classList.remove("is-resizable-vertical");
445+
currentClassNames.remove("is-resizable-vertical");
442446
}
443-
447+
444448
if (resizeDirections.right) {
445-
nodeContentRef.current.classList.add("is-resizable-horizontal");
449+
currentClassNames.add("is-resizable-horizontal");
446450
}
447451
if (resizeDirections.bottom) {
448-
nodeContentRef.current.classList.add("is-resizable-vertical");
452+
currentClassNames.add("is-resizable-vertical");
449453
}
450454
}
451455
}); // need to be done everytime a property is changed and the element is re-rendered, otherwise the resizing class is lost
@@ -701,6 +705,10 @@ export function NodeContent<CONTENT_PROPS = any>({
701705
const nextHeight = resizeDirections.bottom
702706
? (height ?? originalSize.current.height ?? 0) + d.height
703707
: undefined;
708+
if (nextWidth || nextHeight) {
709+
const currentClassNames = nodeContentRef.current.classList;
710+
currentClassNames.add("was-resized");
711+
}
704712
if (nextWidth) {
705713
nodeContentRef.current.style.width = `${nextWidth}px`;
706714
}

src/extensions/react-flow/nodes/_nodes.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
box-shadow: 0 0 0 6 * $reactflow-node-border-width rgba($reactflow-edge-stroke-color-selected, 0.05);
5151
}
5252

53-
&.is-resizable-vertical {
53+
&.was-resized.is-resizable-vertical {
5454
max-height: unset;
5555
}
5656
}

0 commit comments

Comments
 (0)