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: pageX and pageY coords are not passed to MouseEvent from pointer() call #1037

Open
sf-kialo opened this issue Aug 17, 2022 · 2 comments · May be fixed by #1039
Open

14.4: pageX and pageY coords are not passed to MouseEvent from pointer() call #1037

sf-kialo opened this issue Aug 17, 2022 · 2 comments · May be fixed by #1039
Labels
bug Something isn't working

Comments

@sf-kialo
Copy link

sf-kialo commented Aug 17, 2022

Reproduction example

https://codesandbox.io/s/heuristic-lake-3rk90q?file=/src/App.js

Prerequisites

  1. Set up any page that listens to MouseEvent and log the pageX and pageY properties of the event (as specified in the docs)
  2. Simulate a user.pointer event with additional pageX and pageY coords passed like await user.pointer({target: anyTarget, coords: { pageX: 100, pageY: 100 }})
  3. Expect the logs to contain the previously defined values for pageX and pageY.

Expected behavior

The properties are properly passed to the mouse event and get logged correctly.

Works correctly in 14.3.

Actual behavior

The value of these properties is undefined.

Broken as of 14.4.0.

User-event version

14.4.3

Environment

See sandbox

Additional context

When the assignProps was changed in this commit, those two properties were omitted.

@sf-kialo sf-kialo added bug Something isn't working needs assessment This needs to be looked at by a team member labels Aug 17, 2022
@sf-kialo sf-kialo changed the title pageX and pageY coords are not passed to MouseEvent from pointer() call 14.4: pageX and pageY coords are not passed to MouseEvent from pointer() call Aug 17, 2022
@ph-fritsche ph-fritsche removed the needs assessment This needs to be looked at by a team member label Aug 17, 2022
@ph-fritsche ph-fritsche linked a pull request Aug 18, 2022 that will close this issue
2 tasks
@liamcmitchell-sc
Copy link

Note that from JSDOM@22 pageX/Y/offsetX/Y will alias to clientX/Y until layout support is added:
https://github.com/jsdom/jsdom/blob/a39e0ec4ce9a8806692d986a7ed0cd565ec7498a/lib/jsdom/living/events/MouseEvent-impl.js#L16-L31

You can do this yourself as a workaround:

Object.defineProperties(MouseEvent.prototype, {
  pageX: {
    get() {
      return this.clientX
    },
  },
  pageY: {
    get() {
      return this.clientY
    },
  }
})

Then use x and y in pointer actions:

await user.pointer({
  coords: { x: 100, y: 100 }
})

Using x/y instead of clientX/clientY because of #1139

@su-kialo
Copy link

This is still broken as of 14.5.1.

In fact, it's even more broken as the default state is now undefined instead of 0 due to the changes made in the following commit, where pageX and pageY are no longer being initialised:

2852509#diff-3efbb708c7e683da7e8bed053d5b386baa2bf8489e799d1a931db3c4299910c2L43

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.

4 participants