Skip to content

Commit 25fecff

Browse files
Copilotmikebarkmin
andcommitted
Fix create new on edge drop for array elements
Co-authored-by: mikebarkmin <2592379+mikebarkmin@users.noreply.github.com>
1 parent 2976af7 commit 25fecff

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

src/MemoryView.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,22 @@ export const MemoryView = () => {
190190

191191
if (node?.type == "object" && reactFlowInstance != null) {
192192
const objNode: ObjectNodeType = node as any;
193-
const objKlass = memory.klasses[objNode.data["klass"]];
194-
if (!objKlass) return;
195-
const klassName =
196-
objKlass.attributes[connectingNode.current.handleId || ""];
193+
194+
// Special handling for Array elements
195+
let klassName: string;
196+
if (objNode.data.klass === "Array") {
197+
// For array elements, get the dataType from the specific element
198+
const handleId = connectingNode.current.handleId || "";
199+
const elementAttribute = objNode.data.attributes[handleId];
200+
if (!elementAttribute) return;
201+
klassName = elementAttribute.dataType;
202+
} else {
203+
// For regular objects, look up the type from the class definition
204+
const objKlass = memory.klasses[objNode.data["klass"]];
205+
if (!objKlass) return;
206+
klassName = objKlass.attributes[connectingNode.current.handleId || ""];
207+
}
208+
197209
const klass = memory.klasses[klassName];
198210

199211
const { clientX, clientY } =

0 commit comments

Comments
 (0)