Skip to content

fix(memory-graph): enable touch and mobile node dragging and interaction - #1639

Open
Adityakk9031 wants to merge 1 commit into
supermemoryai:mainfrom
Adityakk9031:fix/memory-graph-touch-node-drag
Open

fix(memory-graph): enable touch and mobile node dragging and interaction#1639
Adityakk9031 wants to merge 1 commit into
supermemoryai:mainfrom
Adityakk9031:fix/memory-graph-touch-node-drag

Conversation

@Adityakk9031

Copy link
Copy Markdown
Contributor

Problem

In packages/memory-graph/src/canvas/input-handler.ts, desktop mouse interaction (onMouseDown) tests the spatial index (this.spatialIndex.queryPoint) to detect when a node is clicked or dragged.

However, touch interaction (onTouchStart) unconditionally initiated a canvas pan (this.isPanning = true) for single touches without querying the spatial index for a node hit. Consequently:

  • On smartphones, tablets, iPads, and touch-screen laptops, graph nodes were completely undraggable.
  • Attempting to drag or reposition a node on touch screens panned the entire canvas viewport rather than dragging the selected node.

Solution

  1. Updated onTouchStart to query this.spatialIndex.queryPoint(startWorld.x, startWorld.y) before defaulting to panning. If a node is hit, it sets this.draggingNode = node and invokes onNodeDragStart(node.id, node) while disabling viewport panning.
  2. Updated onTouchMove to reposition the active draggingNode (fx, fy, x, y) and request canvas re-renders when a node is being dragged on touch.
  3. Updated onTouchEnd to clear fixed drag coordinates (fx/fy), reset draggingNode, and fire onNodeDragEnd().
  4. Recorded touchStartNodeId at touch start so tap-to-select cleanly triggers onNodeClick upon tap release without interference from sub-threshold finger jitter.
  5. Added unit tests in packages/memory-graph/src/__tests__/input-handler-touch.test.ts verifying node dragging on touch, viewport panning on empty space, and tap selection.

Verification

Ran bun test packages/memory-graph/src/__tests__/input-handler-touch.test.ts (all 8 tests passed).

@Adityakk9031

Copy link
Copy Markdown
Contributor Author

Hey @Dhravya @MaheshtheDev, could you please take a look at this fix when you have a moment? Thank you!

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.

1 participant