fabricjs / fabric.js

Javascript Canvas Library, SVG-to-Canvas (& canvas-to-SVG) Parser
http://fabricjs.com
Other
29.07k stars 3.51k forks source link

[Bug?]: Support to ActiveSelection stack operation is gone #9730

Open ShaMan123 opened 7 months ago

ShaMan123 commented 7 months ago

Support to ActiveSelection stack operations is gone in v6 In v5 you could do activeSelection.sendBackwards(). Group was not interactive so all selected objects were top level objects, direct descendants of canvas, so it made sense to handle moving them in the stack. However, in v6 a selection can contain objects from different levels of the object tree, performing stack operations on the selection will involve different stacks. It can be supported but it is a question if it should.

The issue is that it is breaking to do the following: canvas.sendBackwards(activeSelection)

I think it might be best to make the following condition stricter: https://github.com/fabricjs/fabric.js/blob/631fe9bd7bd529a32c67f58a2b790b785ff04cf0/src/Collection.ts#L219

into idx > 0

From v5:

Screenshot 2024-03-13 at 13 26 40
asturur commented 7 months ago

Why you say is gone? With top level objects is still working properly, correct?

ShaMan123 commented 7 months ago

No that I see

asturur commented 7 months ago

Ok we have to decide if it is a regression or not and what to do.

ShaMan123 commented 7 months ago

In fact since we introduced the parent property it is simple to re-expose object level stack methods

ShaMan123 commented 7 months ago

Reconsidering this... Since all the stack methods have been renamed and moved to the stack itself I don't think this is breaking or that we should support it

asturur commented 7 months ago

i didn't give much time to this issue, but for first level objects could make sense. We don't need to rush to put it back. Before you could select 2 objects and say, send both of those back or front for example. If the developer is using nested selections the responsibilty of not doing it when dealing with mixed stacks is on the dev not on us, that can be clarified. We can keep track of this and decide when we have time.