deathbeds / ipydrawio

A standalone embedding of the FOSS drawio / mxgraph package into jupyterlab
https://ipydrawio.rtfd.io
Apache License 2.0
51 stars 4 forks source link

Using too many shapes yields strange effects #85

Closed nlooije closed 2 years ago

nlooije commented 2 years ago

Description

As title suggests, adding too many shapes causes weird effects in the editor:

drawio1

When adding the latest shape, the focus is shifted to the top-left corner of the canvas where it shows a text input. Scrolling back the widgets back into view, all shapes except the last one are selectable. Trying to delete the last shape yields a TypeError:

app.min.js:1976 Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
    at mxCodec.encodeCell (app.min.js:1976)
    at mxObjectCodec.a.encodeObject (app.min.js:1996)
    at mxObjectCodec.encode (app.min.js:1981)
    at mxCodec.encode (app.min.js:1975)
    at Editor.getGraphXml (app.min.js:2095)
    at Editor.getGraphXml (app.min.js:10518)
    at App.EditorUi.getXmlFileData (app.min.js:10724)
    at App.EditorUi.getFileData (app.min.js:10735)
    at App.<anonymous> (app.min.js:11034)
    at app.min.js:272

After which none of the other shapes are selectable.

Reproduce

See GIF above, tested in ipydrawio 1.1.3 and 1.2.0 (binder)

  1. Start a fresh instance of Diagram
  2. Add 8 shapes, these are placed without problems
  3. Adding a next shape (9) cause a shift of focus.

The problem seems to occur when object with id=10 is added. Note that a fresh diagram starts with two cells already defined with id=0 and 1 Adding 9 shapes as above leads to the final shape having id=10. Similarly, adding two shapes, removing them, and adding seven shapes yields the same problem as the final shape still has id=10

Expected behavior

No issues adding more than 10 shapes Arrows are also counted as shapes with an id, so this is really impeding making large flowcharts for me

Context

https://mybinder.org/v2/gh/bollwyvl/jupyterlab-drawio/gh-80-widget-custom-shapes?urlpath=lab%2Ftree%2Fdocs%2Ftutorials%2Fworking-with-custom-libraries%2Findex.ipynb

bollwyvl commented 2 years ago

thanks for the report... unfortunately, i have never encountered that error condition, and have built some fairly large things with the editor (though less so through the widget).

I see the reference for binder: does this also occur with the latest conda/pip installable versions?

nlooije commented 2 years ago

Yes, if i spin up a new Jlab instance with a fresh install this error also happens. It seems to be related to the Widget, in the Document I can confirm this is not an issue. Do you see this problem in the binder as well? Or is just on my machine for some reason?

nlooije commented 2 years ago

@bollwyvl just wondering if you are experiencing this as well in the widget? If i run the binder above I get this problem just copying 9 shapes into the canvas. I tested in Chrome, Firefox and Edge -> happens in all browsers. Tested on multiple machines -> happens on my laptop and desktop machine. This bug is hurting my productivity a bit...