Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 28, 2025

Fixes the React Flow node dragging issues where nodes were not responsive to cursor movement and positions were not updating consistently during drag operations.

Problem

The React Flow setup had several issues causing poor dragging behavior:

  1. Position updates only on drag end: Node positions were only updated when change.dragging === false, causing nodes to not follow the cursor during drag operations
  2. Restricted drag area: Dragging was limited to elements with .drag-handle class (only the header area)
  3. Poor user experience: Users couldn't drag nodes smoothly or from anywhere on the node

Solution

Key Changes

MainCanvas.tsx:

  • Removed the change.dragging === false condition in handleNodesChange to enable real-time position updates during dragging
  • Removed dragHandle: '.drag-handle' restriction to make the entire node draggable

StructNode.tsx:

  • Added cursor-move styling to the entire Card component to clearly indicate draggability
  • Removed unnecessary cursor-move from the header-only drag handle

Before vs After

Before:

if (change.type === 'position' && change.position && change.dragging === false) {
  // Only update when dragging stops - choppy movement
}

After:

if (change.type === 'position' && change.position) {
  // Update during dragging - smooth, responsive movement
}

Testing

Verified that both User and Profile struct nodes are now:

  • ✅ Fully draggable from anywhere on the node
  • ✅ Responsive to cursor movement in real-time
  • ✅ Position updates correctly during and after drag operations
  • ✅ No regression in other React Flow features (selection, connections, etc.)

Working React Flow Nodes

The screenshot shows the application with draggable struct nodes where the Profile node has been successfully moved to position (77, 20) as shown in the Node Properties panel.

Impact

This fix resolves the core usability issue where users couldn't effectively drag and position struct nodes in the visual mapping interface, which is essential for creating clear and organized struct mapping diagrams.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

… real-time position updates

Co-authored-by: thitiph0n <42302705+thitiph0n@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] when drage node it's not reacttive by the cursor. and sometime position not changes. check the reactflow setup Fix React Flow node dragging - nodes not reactive to cursor and position updates Aug 28, 2025
@Copilot Copilot AI requested a review from thitiph0n August 28, 2025 01:28
Copilot finished work on behalf of thitiph0n August 28, 2025 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants