svg.js icon indicating copy to clipboard operation
svg.js copied to clipboard

ungroup() reorders nodes

Open samhocevar opened this issue 3 years ago • 2 comments

Bug report

Fiddle

https://jsfiddle.net/3rof824w/

var canvas = SVG().addTo('#canvas').size('100%', '100%')
g = canvas.group()
g.add(canvas.rect(100, 100).move(50,50).fill('red'))
canvas.rect(100, 100).move(100, 100).fill('blue')
g.ungroup()

Explanation

Ungrouping g brings the red square to the front, because it is inserted after the blue square. I would expect ungrouped nodes to be inserted at the position of the original group.

samhocevar avatar Feb 26 '21 13:02 samhocevar

FYI here is my implementation:

function ungroup_in_place(g) {
    for (let e of g.children())
        g.before(e);
    g.remove();
}

samhocevar avatar Feb 26 '21 13:02 samhocevar

good catch

Fuzzyma avatar Feb 26 '21 16:02 Fuzzyma

seems like this was fixed long time ago

Fuzzyma avatar Sep 03 '23 08:09 Fuzzyma