Skip to content

Commit a30604a

Browse files
committedMay 30, 2024
close add node
1 parent f963198 commit a30604a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed
 

‎crewai-reactflow/src/App.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// App.js
22

3-
import React, { useState } from 'react';
3+
import React, { useState, useEffect, useCallback } from 'react';
44
import ReactFlow, {
55
ReactFlowProvider,
66
addEdge,
@@ -57,6 +57,21 @@ const Flow = () => {
5757
setContextMenu(null);
5858
};
5959

60+
const handlePaneClick = useCallback((event) => {
61+
if (contextMenu) {
62+
setContextMenu(null);
63+
}
64+
}, [contextMenu]);
65+
66+
useEffect(() => {
67+
const paneElement = document.querySelector('.react-flow__pane');
68+
paneElement.addEventListener('mousedown', handlePaneClick);
69+
70+
return () => {
71+
paneElement.removeEventListener('mousedown', handlePaneClick);
72+
};
73+
}, [handlePaneClick]);
74+
6075
return (
6176
<div
6277
style={{ width: '100%', height: '100vh', position: 'relative' }}

0 commit comments

Comments
 (0)
Failed to load comments.