Skip to content

Commit

Permalink
feat(canvas): persist group node dimensions on resize
Browse files Browse the repository at this point in the history
- Add `setNodeStyle` to update node dimensions when resizing
- Ensure group node width and height are saved in node data
- Improve group node resize handling with persistent styling
  • Loading branch information
CH1111 committed Mar 11, 2025
1 parent 5cc802b commit 7af48b6
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { useEditorPerformance } from '@refly-packages/ai-workspace-common/contex
import { useCanvasContext } from '@refly-packages/ai-workspace-common/context/canvas';
import { useSetNodeDataByEntity } from '@refly-packages/ai-workspace-common/hooks/canvas/use-set-node-data-by-entity';
import { useThrottledCallback } from 'use-debounce';
import { useNodeData } from '@refly-packages/ai-workspace-common/hooks/canvas/use-node-data';

interface GroupMetadata {
label?: string;
Expand Down Expand Up @@ -71,6 +72,7 @@ export const GroupNode = memo(
const { addNode } = useAddNode();
const { selectNodeCluster, groupNodeCluster, layoutNodeCluster } = useNodeCluster();
const setNodeDataByEntity = useSetNodeDataByEntity();
const { setNodeStyle } = useNodeData();

// Memoize node and its measurements
const node = useMemo(() => getNode(id), [id, getNode]);
Expand Down Expand Up @@ -429,6 +431,10 @@ export const GroupNode = memo(
target.style.top = `${newTop}px`;

setSize({ width: newWidth, height: newHeight });
setNodeStyle(id, {
width: `${newWidth}px`,
height: `${newHeight}px`,
});
}}
hideDefaultLines={true}
className={`!pointer-events-auto ${!isHovered ? 'moveable-control-hidden' : 'moveable-control-show'}`}
Expand Down

0 comments on commit 7af48b6

Please sign in to comment.