fabricjs / fabric.js

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

[bug/feature?] nested multi selections #9600

Open asturur opened 6 months ago

asturur commented 6 months ago

Looking at the nestedSelection use case

image

as of now an active selection that span across groups can't update the groups themselves. The update works only when the multi selection is dissolved.

One of the reasons is that the events that the layoutManager subscribe the objects to moving / scaling events but those do not fire where the activeSelection is being manipulated.

objectCaching or not doesn't change.

asturur commented 6 months ago

In this screenshot i moved the 2 black circles but they are not updated

image
ShaMan123 commented 6 months ago

So it is caching, The only thing needed is to update the dirty flagging in FabricObject#_set It checks for group but should check for parent also

asturur commented 6 months ago

i m not sure i quickly checked with objectCaching false and did not work either. I will look on it later to undertand better, right now i m trying to preserve old code pr/requests that are based on old js code

ShaMan123 commented 6 months ago

So maybe it is because group rendering skips selected objects

asturur commented 6 months ago

Also with nested feature look at correctness of https://github.com/fabricjs/fabric.js/pull/7893 toObject export

ShaMan123 commented 6 months ago

You are right about the layout manager event subscription.

https://github.com/fabricjs/fabric.js/blob/84d20dab5f8ed2da3d43f516201bdfc6fd3aa963/src/LayoutManager/LayoutManager.ts#L62-L96

We need to trigger layout both on the active selection and the parent

asturur commented 6 months ago

that is what i tried right away ( is buried in a commit i did by error while capturing the test case )

One of the reasons is that the events that the layoutManager subscribe the objects to moving / scaling events but those do not fire where the activeSelection is being manipulated.

This was my opening consideration. active selection scaling does not trigger an object scaling. But anyway i ll get to it, i want to use this issue as a way to understand better the mechanism and relationship