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

14.4: pointermove events no longer trigger #1047

Open
dermoumi opened this issue Aug 27, 2022 · 4 comments · May be fixed by #1216
Open

14.4: pointermove events no longer trigger #1047

dermoumi opened this issue Aug 27, 2022 · 4 comments · May be fixed by #1216
Labels
bug Something isn't working

Comments

@dermoumi
Copy link

dermoumi commented Aug 27, 2022

Reproduction example

https://codesandbox.io/s/userevent-touchmove-skz767?file=/src/App.test.js

Prerequisites

  1. Use version >= 14.4.0
  2. Setup a page that listens to pointerdown and pointermove, and logs them.
  3. Trigger pointer events in the test like the following:
    const touchable = screen.getByTitle('container')
    await user.pointer([
      {
        keys: "[TouchA>]",
        target: touchable,
        coords: { x: 100, y: 100 },
      },
      {
        pointerName: "TouchA",
        target: touchable,
        coords: { x: 125, y: 100 },
      },
    ]);

Expected behavior

The new coordinates from the second pointermove event should be logged. (125, 100)

Actual behavior

The initial cordinate from the initial pointerdown event are logged. (100, 100)

User-event version

14.4.0

Environment

Testing Library framework:

JS framework:

Test environment:

DOM implementation:

Additional context

Works just fine on version 14.3.0

@dermoumi dermoumi added bug Something isn't working needs assessment This needs to be looked at by a team member labels Aug 27, 2022
@ph-fritsche
Copy link
Member

Thanks for the report ❤️

There is a typo in the helper:

positionA.coords?.x !== positionB.coords?.y ||
positionA.coords?.y !== positionB.coords?.y ||

@ph-fritsche ph-fritsche removed the needs assessment This needs to be looked at by a team member label Aug 27, 2022
@maxired
Copy link

maxired commented Nov 15, 2022

@ph-fritsche any plan to fix this ?

@GadgetBlaster
Copy link

I'm running into this bug as well. The onMouseMove event is only called when the y coordinate changes. I guess I'll downgrade until this is fixed.

@pjho
Copy link

pjho commented Jun 14, 2024

I dug in to this today and realised while there is a bug in the isDifferentPointerPosition util that wasn't what was causing our tests to fail in versions >= 14.4.0.

Our tests were all specified with clientX & clientY. Changing these to x and y respectively allows our tests to pass again.

Breaks in >= 14.4.0:

await user.pointer([
  {
    keys: '[MouseLeft>]',
    target: el,
    coords: { clientX: 100, clientY: 100 },
  },
  {
    coords: { clientX: 200, clientY: 200 },
  },
  {
    keys: '[/MouseLeft]',
  },
]);

Fixed in >= 14.4.0:

await user.pointer([
  {
    keys: '[MouseLeft>]',
    target: el,
    coords: { x: 100, y: 100 },
  },
  {
    coords: { x: 200, y: 200 },
  },
  {
    keys: '[/MouseLeft]',
  },
]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants