Skip to content

feat: freeze edges while dragging associated nodes#310

Merged
jeff-phillips-18 merged 1 commit intopatternfly:mainfrom
shivamG640:freeze-edge-during-node-drag
Mar 19, 2026
Merged

feat: freeze edges while dragging associated nodes#310
jeff-phillips-18 merged 1 commit intopatternfly:mainfrom
shivamG640:freeze-edge-during-node-drag

Conversation

@shivamG640
Copy link
Contributor

@shivamG640 shivamG640 commented Mar 17, 2026

What

Closes #304

Description

When a node is dragged, its associated edges currently move along with it, which can result in an undesirable UX in scenarios where nodes need to be dropped onto edges. This PR enables an optional static behavior for DefaultEdge during node drag operations, allowing edges to remain fixed while the node is being moved.

Type of change

  • Feature

Screen shots / Gifs for design review

Screencast.From.2026-03-17.16-32-21.mp4

@patternfly-build
Copy link

patternfly-build commented Mar 17, 2026

@shivamG640 shivamG640 marked this pull request as ready for review March 17, 2026 13:58
Copy link
Member

@jeff-phillips-18 jeff-phillips-18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @shivamG640! Looking really good. A few comments.

/** A ref to add to the node for dropping. Part of WithDndDropProps */
dndDropRef?: ConnectDropTarget;
/** Flag if the current drag operation is dragging something that can be dropped on the edge */
droppable?: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add a new property like endpointDragging which would indicate either the source or target node is being dragged. Applications that allow dropping on an edge may need to differentiate.

This would require the new property and for endpointDragging to be determined in edgeDropTargetSpec.

Here is what I came up with for determining this value:

const edgeEndpointIsDragging = (monitor: any, props: EdgeComponentProps) => {
  if (!monitor.isDragging()) {
    return false;
  }
  if (monitor.getItemType() === NODE_DRAG_TYPE) {
    return (
      monitor.getItem().element.id === props.element.getSource().getId() ||
      monitor.getItem().element.id === props.element.getTarget().getId()
    );
  }
  return false;
};

const edgeDropTargetSpec = 
...
    collect: (monitor, props) => ({
      droppable: monitor.isDragging(),
      dropTarget: monitor.isOver(),
      canDrop: monitor.canDrop(),
      endpointDragging: edgeEndpointIsDragging(monitor, { element: props.element as Edge })
    })

terminalType={endTerminalType}
status={endTerminalStatus}
highlight={dragging || hover}
startPoint={bendpoints[bendpoints.length - 1] || startPointRef.current}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to set startPoint and endPoint for both terminals to the frozen values when shouldFreeze is true. This means determining them each time (based on bendpoints) and saving a ref to use when frozen.

See https://github.com/patternfly/react-topology/blob/main/packages/module/src/components/edges/terminals/DefaultConnectorTerminal.tsx#L61-L64

@shivamG640
Copy link
Contributor Author

@jeff-phillips-18, Thanks for taking the time to review and share your feedback.
I’ve added another commit incorporating the suggested changes. If everything looks good to you, I can squash the commits into a single one for merging. I’m also happy to make any further improvements if needed.

Copy link
Member

@jeff-phillips-18 jeff-phillips-18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks @shivamG640. Yes, please squash the commits.

@shivamG640 shivamG640 force-pushed the freeze-edge-during-node-drag branch from 80538fa to 8e45bd4 Compare March 19, 2026 13:06
@shivamG640
Copy link
Contributor Author

Ready to merge. Thanks again for your help on this! @jeff-phillips-18

@jeff-phillips-18 jeff-phillips-18 merged commit 661caa3 into patternfly:main Mar 19, 2026
8 checks passed
@github-actions
Copy link

🎉 This PR is included in version 6.5.0-prerelease.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@shivamG640 shivamG640 deleted the freeze-edge-during-node-drag branch March 20, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Edges - Enable static DefaultEdge behavior while dragging associated nodes

3 participants