Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Expose the clear action as a button named by `onClearanceText`, and as disabled if the Select is disabled.
- Prevent any interaction with the clear action of a disabled Select.
- Without `fill`, the wrapper element used for `wrapperProps` and test IDs is displayed inline, like the Select itself.
- `<NodeContent />`
- restore the saved height of vertically resized nodes, including sticky notes, while honoring configured resize limits

## [26.2.1] - 2026-11-02

Expand Down
44 changes: 44 additions & 0 deletions src/extensions/react-flow/nodes/NodeContent.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from "react";
import { render, screen } from "@testing-library/react";
import { ReactFlowProvider } from "@xyflow/react";

import "@testing-library/jest-dom";

import { NodeContent } from "./NodeContent";

describe("NodeContent vertical sizing", () => {
it.each([
{ savedHeight: 900, maxHeight: undefined, expectedMaxHeight: "none" },
{ savedHeight: 900, maxHeight: 600, expectedMaxHeight: "600px" },
{ savedHeight: undefined, maxHeight: undefined, expectedMaxHeight: "400px" },
])(
"applies max-height $expectedMaxHeight with saved height $savedHeight and resize limit $maxHeight",
({ savedHeight, maxHeight, expectedMaxHeight }) => {
render(
<ReactFlowProvider>
<style>
{'[data-testid="node-content"] { min-width: 75px; min-height: 75px; max-height: 400px; }'}
</style>
<NodeContent
data-testid="node-content"
label="Note"
size="medium"
minimalShape="none"
handles={[]}
onNodeResize={jest.fn()}
nodeDimensions={savedHeight ? { width: 300, height: savedHeight } : undefined}
resizeMaxDimensions={maxHeight ? { height: maxHeight } : undefined}
/>
</ReactFlowProvider>,
);

const node = screen.getByTestId("node-content");
expect(node).toHaveStyle({ maxHeight: expectedMaxHeight });
if (savedHeight) {
const height = Math.min(savedHeight, maxHeight ?? Infinity);
expect(node).toHaveStyle({ height: `${height}px` });
expect(node.parentElement).toHaveStyle({ height: `${height}px` });
}
},
);
});
4 changes: 3 additions & 1 deletion src/extensions/react-flow/nodes/NodeContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -535,13 +535,15 @@ export function NodeContent<CONTENT_PROPS = React.HTMLAttributes<HTMLElement>>({
highlightColor,
);

// A saved height must override the default CSS height cap, just as an interactive resize does.
const resizableMaxHeight = resizeMaxDimensions?.height ?? (nodeDimensions?.height ? "none" : undefined);
const resizableStyles =
isResizable && (width ?? 0) + (height ?? 0) > 0
? {
width,
height,
maxWidth: resizeDirections.right ? (resizeMaxDimensions?.width ?? undefined) : undefined,
maxHeight: resizeDirections.bottom ? (resizeMaxDimensions?.height ?? undefined) : undefined,
maxHeight: resizeDirections.bottom ? resizableMaxHeight : undefined,
}
: {};

Expand Down
Loading