-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(): perform layout on poly change + initialization object subscription #9537
Conversation
Build Stats
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DONE
faddc10
to
f61df2f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed group layout edge case + border issue when Poly#exactBoundingBox
src/shapes/Group.ts
Outdated
const layoutManager = | ||
// not destructured on purpose here. | ||
options.layoutManager || new LayoutManager(); | ||
this.layoutManager = layoutManager; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i removed destructuring because is extremely noisy in the constructor, please don't change this since the change was fresh and commented. the rest operator on the function parameter becomes larger code and also slower. We do not get any benefit from extracting the layoutManager and assign it as a default in the constructor, since the layout manager is not used in the super class of the group.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind about destruction, though having super setting values has become something I hate. I have encountered a number of hard to debug issues caused by fabric's usage of it. But that is a different topic.
Your change not to destruct the object introduced a regression and confusion.
It has to be set on the instance before calling performLayout or else the layout manager will not subscribe the objects.
Now, after you made group bind a layout manager I think we should remove that check all together but we need to consider how it will affect sharing a layout manager between groups and if we allow it or not.
So yes I prefer destructing because there is less ambiguity. It is just that a naive syntax introduced bugs.
You did not write why it was not destructed on purpose in the comment but I guessed that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To conclude, the syntax is 99% of the times something I can live with and bugs suck
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think the bug is fixed by moving line 150 to 142. Correct?
Destructuring options in the constructor is what i asked you to not change.
Also want to clarify the destructuring or not has nothing to do with the bug.
The bug was to assign the layout manager after perform layout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is also unclear why we need to keep that check on the subscription
(this one: https://github.com/fabricjs/fabric.js/blob/master/src/LayoutManager/LayoutManager.ts#L109)
since we have 1 group 1 layout manager, and that was the goal of the changes i made before merging the pr.
Is there any case in which we end up executing that line with a layout manager and a group that are not bound together?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any case in which we end up executing that line with a layout manager and a group that are not bound together?
That is what I mentioned
Now, after you made group bind a layout manager I think we should remove that check all together but we need to consider how it will affect sharing a layout manager between groups and if we allow it or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have PR with only the part 'fix(): perform layout on poly change + initialization object subscription' ?
The issues with exact bounding box are there, but i don't think excluding the stroke calculation for all the methods that usually account for it is a good without evaluating other options first
@asturur I know how much you hate strokeUniform. It all comes down to math. I fixed the math and everything worked. |
we need to make a good step forward. Once that is clarified we can move on. It doesn't look good to have '_getTransformedDimensions' to have to know if someone else will have to take in account for stroke. It doesn't even look good the boolean we have right now in getNonTransformedDimensions for polygon/polyline. The exact bounding box has so much different math from text and rect that is probably fine as its own class with its own geometry methods. Who needs exact bounding box can initiate a different kind of polygon or polyline. We can also merge this fix but my intention is to wipe the exact bounding box as they are today because mixed with the other logic they look as bad as the bug we had before having the option to use them. |
Please improve with PR description. |
Until we discuss this together I don't see how to explain it to you more than I have. |
c27ab90
to
49cf575
Compare
5b3ce0a
to
e7412a9
Compare
e7412a9
to
0982164
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about this? Should I extract the exactBoundingBox logic?
0982164
to
29b4d78
Compare
This reverts commit 449f6e0.
29b4d78
to
43c627c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
43c627c
to
406b4fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted the exactBBox fix to a dedicated Pr
So what is left for the layout manager? check that optional binding with the group? |
Yes and deciding about the active selection ref because it is related to |
I have another idea that might make all the hard to reason about correction logic void. |
Motivation
closes #9534
Description
Subscribe to the poly change event to layout group
Changes
exactBoundingBox
Gist
In Action
https://codesandbox.io/p/sandbox/fabric-vanillajs-sandbox-forked-9fgf6r?file=%2Fsrc%2Findex.ts%3A28%2C69