Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

Fix copy-paste of text creating unintended blocks (#7903)

Bently777f7d25bf36
diff --git a/rnd/autogpt_builder/src/components/Flow.tsx b/rnd/autogpt_builder/src/components/Flow.tsx
index bc928730b2..747a4f85d0 100644
--- a/rnd/autogpt_builder/src/components/Flow.tsx
+++ b/rnd/autogpt_builder/src/components/Flow.tsx
@@ -378,7 +378,14 @@ const FlowEditor: React.FC<{
const handleKeyDown = useCallback(
(event: KeyboardEvent) => {
- if (isAnyModalOpen) return; // Prevent copy/paste if any modal is open
+ // Prevent copy/paste if any modal is open or if the focus is on an input element
+ const activeElement = document.activeElement;
+ const isInputField =
+ activeElement?.tagName === "INPUT" ||
+ activeElement?.tagName === "TEXTAREA" ||
+ activeElement?.getAttribute("contenteditable") === "true";
+
+ if (isAnyModalOpen || isInputField) return;
if (event.ctrlKey || event.metaKey) {
if (event.key === "c" || event.key === "C") {
@@ -432,13 +439,15 @@ const FlowEditor: React.FC<{
}
},
[
- addNodes,
- addEdges,
- setNodes,
+ isAnyModalOpen,
+ nodes,
+ edges,
copiedNodes,
+ setNodes,
+ addNodes,
copiedEdges,
+ addEdges,
nodeId,
- isAnyModalOpen,
],
);