Skip to content
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(Canvas): in/out event names were swapped #9396

Merged
merged 7 commits into from
Oct 4, 2023

Conversation

jiayihu
Copy link
Contributor

@jiayihu jiayihu commented Oct 2, 2023

@jiayihu jiayihu changed the title Fix in out event regression Fix canvas in out event firing being swapped Oct 2, 2023
ShaMan123
ShaMan123 previously approved these changes Oct 4, 2023
Update eventData.test.ts.snap
ShaMan123
ShaMan123 previously approved these changes Oct 4, 2023
Copy link
Contributor

@ShaMan123 ShaMan123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed types and added tests

@ShaMan123 ShaMan123 changed the title Fix canvas in out event firing being swapped fix(Canvas): in/out swapped event names Oct 4, 2023
@ShaMan123 ShaMan123 changed the title fix(Canvas): in/out swapped event names fix(Canvas): in/out event names were swapped Oct 4, 2023
@ShaMan123 ShaMan123 merged commit 564c585 into fabricjs:master Oct 4, 2023
21 of 24 checks passed
@jiayihu
Copy link
Contributor Author

jiayihu commented Oct 4, 2023

Why was the type fix reverted? If you use the optional operator, it won't complain if the nextTarget/previousTarget is not passed at all, even if undefined. That's why it was not giving an error. Whereas nextTarget: fabric.Object | undefined means that it must be explicitly provided, even if undefined, which is what we do.

const exit = new MouseEvent('mousemove', { clientX: 20, clientY: 20 });
canvas._onMouseMove(enter);
canvas._onMouseMove(exit);
expect(targetSpy.mock.calls).toMatchSnapshot();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ShaMan123 This could have been targetSpy.mock.calls.map(([event]) => event), then even use toMatchInlineSnapshot for a much smaller and nicer snapshot, while being convenient.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes.
stop toMatchSnapthot.

@ShaMan123
Copy link
Contributor

Why was the type fix reverted? If you use the optional operator, it won't complain if the nextTarget/previousTarget is not passed at all, even if undefined. That's why it was not giving an error. Whereas nextTarget: fabric.Object | undefined means that it must be explicitly provided, even if undefined, which is what we do.

I didn't look into it but build was failing.
My bad

@jiayihu jiayihu deleted the jiayi/hovering branch October 4, 2023 21:14
@asturur
Copy link
Member

asturur commented Oct 7, 2023

@ShaMan123 @jiayihu you are welcome to merge laser focused fixes like this but:

  • The source of the commit that broke the code shouldn't be hidden in comments, needs to be in PR description
  • as pointed out in comments snapshot tests are uneffective so please let's stop adding snapshot tests for those kinds of thing.

We can simply say:
theMock has been called with 'mousein' or whatever, a blanket cover all of the event data isn't a good idea imho

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants