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

This commit is contained in:
Bently
2024-08-27 11:49:35 +01:00
committed by GitHub
parent ea6f37bf98
commit 777f7d25bf

View File

@@ -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,
copiedNodes,
copiedEdges,
nodeId,
isAnyModalOpen,
nodes,
edges,
copiedNodes,
setNodes,
addNodes,
copiedEdges,
addEdges,
nodeId,
],
);