I have a diagram transaction where I want to update images (icons) bound by the source property on a Picture shape. Very close to the following:
diagram.model.commit(model => {
model.nodeDataArray.forEach(node => {
model.setDataProperty(node, 'icon', newIcon);
}
});
The model is updated right away after commit, and the network tab shows that the request is made for the new image. The old image is also removed. However, the new image does not show - it is simply blank. It is not until there is an interaction with the diagram (canvas click, link click, etc) that the icon shows up.
If I call diagram.redraw()
after the commit, nothing changes. However, if I wrap it in a setTimeout
with a 2 second delay, it forces the image to show properly. Is there a better way to ensure that the new icon will show, whether it’s a different API or hooking to a different event on the diagram?
Thank you in advance!