-
-
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(ActiveSelection): make sure canvas is in charge of setting initial coords #9322
Conversation
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.
ready for review
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.
this fix is ready
the test is broken on master
The changes is ok for me, but we should comunicate somewhere that using ActiveSelection manually is becoming highly not suggested. |
src/shapes/ActiveSelection.spec.ts
Outdated
]), | ||
viewportTransform: [2, 0, 0, 0.5, 400, 150], | ||
}); | ||
expect(canvas.getActiveSelection().getCoords()).toMatchSnapshot(); |
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.
let's test by picking aCoords and lineCoords that is what are we testing today.
We are testing that those are correct, without the need of being recalculated.
getCoords return an array and is mostly for internal usage of calculations, if we snapshot aCoords and lineCoords we also see tl,tr,bl,br.
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.
We are testing that those are correct, without the need of being recalculated.
They are not recalcuated.
I just have in mind #8767 so I avoid lineCoords already but whatever
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.
they are not recalculated no, but no one knows it, is not written the test is not explcit.
if getCoords change or recalculation becomes default, this test doesn't break but also becomes uneffective.
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 do not follow
What should be changed?
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.
oh i thought you changed because i have seen outdated tag on the discussion
i ll change it never mind
@@ -55,4 +56,20 @@ describe('ActiveSelection', () => { | |||
selection.add(new FabricObject({ left: 50, top: 50, strokeWidth: 0 })); | |||
expect(selection.item(0).getCenterPoint()).toEqual({ x: 50, y: 50 }); | |||
}); | |||
|
|||
it('sets coords after attaching to canvas', () => { |
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.
Isn't this a canvas test? is the canvas executing the new code no?
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.
true, I have no idea where it should belong
I was thinking to make the constructor protected. Then you get a TS error you can ignore. |
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.
ok
Motivation
Description
Moved the call to
setCoords
from the constructor.It should not be there because the canvas ref is being set after that possibly, leading to wrong coords due to vpt.
Changes
Gist
In Action