DiagramEvent SubGraphExpanded Error

we sometimes get this error in firefox and many customers too. what could the solution be our script looks like :

pvpDiagram = $$(go.Diagram, “Diagram”, {
SubGraphExpanded: function(e) {
try {
var groups = e.subject;
groups.each(function(g) {
if (g instanceof go.Group) {
pvpDiagram.model.setDataProperty(g.data, ‘SubGraphExpanded’, true);
}
})
} catch (ex) {
var place = "IPRO-CHART: SubGraphExpanded ";
ex.name = place + ex.name;
writeToLog(ex, 0, LOGLEVEL.ERROR);
}
},

I do not know. Is the code that you quoted in the pvpinit function?

Has the GoJS library been loaded only once, and not more than once? It should not be loaded more than once, and also not multiple versions or debug and non-debug.

yes the code is in the pvpinit function

I only call these files from gojs
go.js
GuidedDraggingTool.js
jquery.js

i have this file ( go_2.1.6.js ) in the dictionary but i don’t call it may that be because of itAnmerkung 2020-08-24 144932

Yes, delete the old file.

I deleted it ( go_2.1.6.js ) the error unfortunately still appears

Could you please confirm that the GoJS library is not loaded more than once?

In the debugger what is the object for which there is no “SubGraphExpanded” property? That error message is correct – there is no “SubGraphExpanded” property in the Diagram class. But there is a “SubGraphExpanded” DiagramEvent that go.GraphObject.make should be recognizing. And I was guessing that the cause for such odd behavior is loading the GoJS library more than once.

you may be right I found a variable that calls go.js file but it is not used anywhere maybe it is because of it.
I have commented this variable. The problem is that this error appear sometimes often and sometimes rarely. i will test again and I get back
Thank you very much for your efforts

i call the GoJs library only once nonetheless appear the Error sometimes only in firfox again but in another Browser dose not appear at all

It is good that you have tried other browsers. I use Firefox as my default browser and have never seen or heard of this kind of error.

How can I reproduce the problem?

SubGraphExpanded: function(e) {
try {
var groups = e.subject;
groups.each(function(g) {
if (g instanceof go.Group) {
pvpDiagram.model.setDataProperty(g.data, ‘SubGraphExpanded’, true);
}
})
} catch (ex) {
var place = "IPRO-CHART: SubGraphExpanded ";
ex.name = place + ex.name;
writeToLog(ex, 0, LOGLEVEL.ERROR);
}
}
you can set in init function this Diagramm Event than should somtimes appear this Error in Firefox
i set the variable SubGraphExpanded on true when you click on the expanded Button in the Group!Anmerkung 2020-08-25 124543 Anmerkung 2020-08-25 124556

and on false when you click on Collapsed button
SubGraphCollapsed: function(e) {
try {
var groups = e.subject;
groups.each(function(g) {
if (g instanceof go.Group) {
pvpDiagram.model.setDataProperty(g.data, ‘SubGraphExpanded’, false);
}
})
} catch (ex) {
var place = "IPRO-CHART: SubGraphCollapsed ";
ex.name = place + ex.name;
writeToLog(ex, 0, LOGLEVEL.ERROR);

  }
},

What Bindings do you have that use “SubGraphExpanded” as a source property name?

You should not be changing the expanded state of the Group in an event handler or listener.

I changed the variable name again from SubGraphExpanded to graphExpan. I set only a variable on true or false
pvpDiagram.model.setDataProperty(g.data, ‘graphExpan’, true);

I don’t change anything I just set a variable ( graphExpan ) to true or false at call the SubGraphExpanded or the SubGraphCollapsed DiagrammEvent

I just tried your code, but using console.log instead of writeToLog.

        $(go.Diagram, "myDiagramDiv", // must be the ID or reference to div
          {
            SubGraphExpanded: function(e) {
              try {
                var groups = e.subject;
                groups.each(function(g) {
                  if (g instanceof go.Group) {
                    myDiagram.model.setDataProperty(g.data, "SubGraphExpanded", true);
                  }
                })
              } catch (ex) {
                console.log(ex);
              }
            },
            SubGraphCollapsed: function(e) {
              try {
                var groups = e.subject;
                groups.each(function(g) {
                  if (g instanceof go.Group) {
                    myDiagram.model.setDataProperty(g.data, "SubGraphExpanded", false);
                  }
                })
              } catch (ex) {
                console.log(ex);
              }
            } 
          })

I am unable to cause any problems.

Is there any chance that you are loading the GoJS library asynchronously and are sometimes executing your initialization code too early?

I don’t know, the bug appears sometimes you have to try several times
my colleague knows the project more than me. I ask him when he comes back from holiday.
i think we are loading the GoJS library in the first

hallo Walter thanks for your help. the go.js library has been called more than once.