You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found another weird case similar to #1320 when using the asynchronous paper mode: After adding a toolsView to an element, I want to (conditionally) hide one of the toolViews (in this example the "Remove" button). This works as expected in the normal synchronous rendering mode, but fails if async: true is set in the paper options.
Here is a modified code from the Hello-world-example to reproduce the problem:
The text was updated successfully, but these errors were encountered:
ialokim
changed the title
Unconditionally shows manually hidden toolViews in async mode
Manually hidden toolView shown after calling addTools in async mode
Mar 17, 2021
I was able to fix this behavior (at least for my use-case) with the following monkey-patch:
joint.dia.ToolView.prototype.configure=function(view,toolsView){this.relatedView=view;this.paper=view.paper;this.parentView=toolsView;this.simulateRelatedView(this.el);// Delegate events in case the ToolView was removed from the DOM and reused.this.delegateEvents();this.show();//addedreturnthis;};joint.dia.ToolsView.prototype.update=function(opt){opt||(opt={});vartools=this.tools;if(!tools)returnthis;varisRendered=this.isRendered;for(vari=0,n=tools.length;i<n;i++){vartool=tools[i];if(!isRendered){// First update executes render()tool.render();}elseif(opt.tool!==tool.cid&&tool.isVisible()){tool.update();}}if(!isRendered){this.mount();// Make sure tools are visible (if they were hidden and the tool removed)//this.blurTool(); //removedthis.isRendered=true;}returnthis;};
Not sure though if that could be a general-purpose solution as the asynchronous rendering scheme might be hurt by the additional call to this.show() inside configure().
I found another weird case similar to #1320 when using the asynchronous paper mode: After adding a
toolsView
to an element, I want to (conditionally) hide one of thetoolView
s (in this example the "Remove" button). This works as expected in the normal synchronous rendering mode, but fails ifasync: true
is set in the paper options.Here is a modified code from the Hello-world-example to reproduce the problem:
In synchronous mode, the remove button is correctly hidden
whereas in asynchronous mode the results looks as follows
I've already looked into the code and suspect https://github.com/clientIO/joint/blob/master/src/dia/ToolsView.mjs#L60 or https://github.com/clientIO/joint/blob/master/src/dia/ToolsView.mjs#L52 to cause the problem as this code might get executed after the manual hiding. A solution might be to (re)set all
_visible
flags of thetoolView
s totrue
directly (synchronously) when callingaddTools
.The text was updated successfully, but these errors were encountered: