z-Index initialization issue in async mode
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.4k
- Forks
- 893
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 26
Description
If I want to have a link displayed below my cells on initialization, it should be as simple as adding z: 0 to the link and z: 1 to the cells while calling the constructor. 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:
var graph = new joint.dia.Graph;
var paper = new joint.dia.Paper({
//async: true,
el: document.getElementById('myholder'),
model: graph,
width: 600,
height: 100,
gridSize: 1
});
var rect = new joint.shapes.standard.Rectangle({
z:1
});
rect.position(100, 30);
rect.resize(100, 40);
rect.attr({
body: {
fill: 'blue'
},
label: {
text: 'Hello',
fill: 'white'
}
});
rect.addTo(graph);
var rect2 = rect.clone();
rect2.translate(300, 0);
rect2.attr('label/text', 'World!');
rect2.addTo(graph);
var link = new joint.shapes.standard.Link({
vertices: [{x: 600, y: 50}],
z:0
});
link.source(rect);
link.target(rect2);
link.addTo(graph);
In synchronous mode, the graph is rendered correctly as

whereas in asynchronous mode the results looks as follows

because the order in the svg tree is not adapted correctly.
Btw, for some reason if I move the source or target (by the corresponding link tools), somehow it seems to re-render and the link is correctly displayed below the rectangle.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the modified Hello-world example using joint.dia.Paper and the async paper option. Start by tracing asynchronous initialization and how the SVG tree is ordered by z values; done means the link with z: 0 is rendered below the cells with z: 1 immediately, without moving a source or target first.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100