Skip to content

Commit 25abdcf

Browse files
mvalancyclaude
andcommitted
Fix camera jump when left-clicking empty space in graph
- Remove context menu from left-click to prevent rapid show/hide cycles - Context menu now only appears on right-click as intended - Fix auto-fit useEffect dependency to prevent unnecessary camera movements - Left-click on empty space now only closes dialogs and clears selections - Eliminates disruptive camera jumps during normal interaction 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 935e29c commit 25abdcf

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

packages/web/src/components/InteractiveGraphVisualization.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,14 +1457,8 @@ export function InteractiveGraphVisualization({ onResetLayout }: InteractiveGrap
14571457
return;
14581458
}
14591459

1460-
// No dialogs open - show the context menu
1461-
const [graphX, graphY] = d3.pointer(event, g.node());
1462-
setContextMenuPosition({
1463-
x: event.clientX,
1464-
y: event.clientY,
1465-
graphX,
1466-
graphY
1467-
});
1460+
// Don't show context menu on single left-click in empty space - only on right-click
1461+
// This prevents camera jumps from rapid context menu show/hide cycles
14681462
});
14691463

14701464
// Add right-click handler for context menu
@@ -3136,9 +3130,10 @@ export function InteractiveGraphVisualization({ onResetLayout }: InteractiveGrap
31363130
}, 1000);
31373131
}, [nodes, initializeVisualization, fitViewToNodes]);
31383132

3139-
// Auto-fit view when component first mounts with nodes
3133+
// Auto-fit view when component first mounts with nodes - using stable dependency
3134+
const hasNodes = nodes.length > 0;
31403135
useEffect(() => {
3141-
if (nodes.length > 0 && svgRef.current) {
3136+
if (hasNodes && svgRef.current) {
31423137
// Check if this is the initial load (no previous transform stored)
31433138
const hasStoredTransform = sessionStorage.getItem('graphViewTransform');
31443139
if (!hasStoredTransform) {
@@ -3179,7 +3174,7 @@ export function InteractiveGraphVisualization({ onResetLayout }: InteractiveGrap
31793174
}
31803175
}
31813176
return undefined;
3182-
}, [nodes.length > 0, fitViewToNodes]);
3177+
}, [hasNodes]); // Removed fitViewToNodes dependency to prevent camera jumps
31833178

31843179
// Expose reset function to parent component
31853180
useEffect(() => {

0 commit comments

Comments
 (0)