Editing Issue with Copied and Pasted Nodes


#1

I have a weird issue with copying and pasting nodes and then editing the text in the fields within the node. For example, this is a picture of a copied and pasted node:
image
When changing a field within the node, it changes it in the copied and original nodes (see the word change):
image
This is very frustrating and I can’t figure out why this is happening. I looked at the actual code that creates the diagram and the new node has a different key:

{ "class": "GraphLinksModel",
  "copiesKey": false,
  "nodeDataArray": [ 
{"text":"complaint", "attributes":[ {"name":"complaint_id", "isUnderline":true},{"isUnderline":false, "name":"date"},{"isUnderline":false, "name":"details"} ], "location":{"class":"go.Point", "x":-1067.4732140787266, "y":-349.542853001186}, "key":-1, "figure":"RoundedRectangle", "type-figure":"RoundedTopRectangle"},
{"text":"item", "attributes":[ {"name":"item_id", "isUnderline":true},{"isUnderline":false, "name":"description"},{"isUnderline":false, "name":"price"} ], "location":{"class":"go.Point", "x":-1063.1732140787267, "y":-129.74285300118615}, "key":-4, "figure":"Rectangle", "type-figure":"Rectangle", "secondary":true},
{"text":"CUSTOMER", "attributes":[ {"name":"CUSTOMER_ID", "isUnderline":true},{"isUnderline":false, "name":"name (first_name, last_name)"},{"isUnderline":false, "name":"ADDRESS (STREET, CITY, STATE, ZIPCODE)"},{"isUnderline":false, "name":"PHONE"},{"isUnderline":false, "name":"email"} ], "location":{"class":"go.Point", "x":-737.4732140787266, "y":-374.0428530011862}, "key":-6, "figure":"Rectangle", "type-figure":"Rectangle", "secondary":true},
{"text":"INVOICE", "attributes":[ {"name":"invoice_id", "isUnderline":true},{"isUnderline":false, "name":"date_in"},{"isUnderline":false, "name":"date_out"} ], "location":{"class":"go.Point", "x":-667.2252448952908, "y":-129.65122497625373}, "key":-7, "figure":"Rectangle", "type-figure":"Rectangle", "secondary":true},
{"text":"invoice_item", "attributes":[ {"name":"quantity", "isUnderline":false} ], "location":{"class":"go.Point", "x":-889.4252448952907, "y":-105.45122497625374}, "key":-8, "figure":"RoundedRectangle", "type-figure":"RoundedTopRectangle"},
{"text":"employee", "attributes":[ {"name":"employee_id", "isUnderline":true},{"isUnderline":false, "name":"name (first_name, last_name)"},{"isUnderline":false, "name":"ADDRESS (STREET, CITY, STATE, ZIPCODE)"},{"isUnderline":false, "name":"hire_date"} ], "location":{"class":"go.Point", "x":-449.47321407872664, "y":-142.0428530011862}, "key":-9, "figure":"Rectangle", "type-figure":"Rectangle", "secondary":true},
{"text":"CUSTOMER", "attributes":[ {"name":"CUSTOMER_ID", "isUnderline":true},{"isUnderline":false, "name":"name (first_name, last_name)"},{"isUnderline":false, "name":"ADDRESS (STREET, CITY, STATE, ZIPCODE)"},{"isUnderline":false, "name":"PHONE"},{"isUnderline":false, "name":"email"} ], "location":{"class":"go.Point", "x":-479.47321407872664, "y":-374.0428530011862}, "key":-10, "figure":"Rectangle", "type-figure":"Rectangle", "secondary":true}
 ],
  "linkDataArray": [ 
{"from":-6, "to":-7, "points":[-616.3193749673985,-220.339047459194,-616.3193749673985,-210.339047459194,-616.3193749673985,-174.99513621772388,-616.2252448952908,-174.99513621772388,-616.2252448952908,-139.65122497625373,-616.2252448952908,-129.65122497625373], "text":"places", "toArrow":"LineFork"},
{"from":-9, "to":-7, "points":[-449.47321407872664,-77.62867453438932,-459.47321407872664,-77.62867453438932,-507.3492294870087,-77.62867453438932,-507.3492294870087,-77.67477081365608,-555.2252448952908,-77.67477081365608,-565.2252448952908,-77.67477081365608], "text":"is assigned", "toArrow":"LineFork", "fromArrow":"LineCircle"},
{"from":-6, "to":-1, "points":[-737.4732140787266,-297.1909502301901,-747.4732140787266,-297.1909502301901,-846.9224328287266,-297.1909502301901,-846.9224328287266,-296.8163988385884,-946.3716515787266,-296.8163988385884,-956.3716515787266,-296.8163988385884], "text":"complains\nabout", "toArrow":"CircleFork", "fromArrow":"DoubleLine"},
{"from":-7, "to":-8, "points":[-667.2252448952908,-77.67477081365608,-677.2252448952908,-77.67477081365608,-713.8721198952908,-77.67477081365608,-713.8721198952908,-77.60021942205452,-750.5189948952907,-77.60021942205452,-760.5189948952907,-77.60021942205452], "text":"includes", "toArrow":"LineFork"},
{"from":-4, "to":-8, "points":[-961.1732140787267,-77.7663988385885,-951.1732140787267,-77.7663988385885,-925.2992294870087,-77.7663988385885,-925.2992294870087,-77.60021942205452,-899.4252448952907,-77.60021942205452,-889.4252448952907,-77.60021942205452], "text":"is on", "toArrow":"LineFork"},
{"from":-4, "to":-1, "points":[-1012.1732140787267,-129.74285300118615,-1012.1732140787267,-139.74285300118615,-1012.1732140787267,-186.91639883858844,-1011.9224328287266,-186.91639883858844,-1011.9224328287266,-234.08994467599072,-1011.9224328287266,-244.08994467599072], "text":"is\ncomplained\nby", "toArrow":"CircleFork"},
{"from":-9, "to":-9, "points":[-207.1655358560704,-77.62867453438932,-181.1655358560704,-77.62867453438932,-181.1655358560704,12.78550393240755,-254.74245541173445,12.78550393240755,-328.3193749673985,12.78550393240755,-328.3193749673985,-13.21449606759245], "text":"manages", "toArrow":"CircleLine", "fromArrow":"BackwardCircleFork"}
 ]}

Interestingly, If I refresh the page, it seems to resolve this issue so that I can interact with each node individually.


#2

By default models do shallow copies of Arrays and their data. Set
https://gojs.net/latest/api/symbols/Model.html#copiesArrays and
https://gojs.net/latest/api/symbols/Model.html#copiesArrayObjects to true.

Please also read https://gojs.net/latest/intro/itemArrays.html#ArraysInModels


#3

Thank you! This is exactly what I was looking for.