Open Georgegriff opened 4 weeks ago
Update:
I did some digging in your code around how you might be determining this and i came across some code referencing pressure, so i tried manually firing the events and it works to "trick" this library into doing long presses, but it's kinda horrible and i had to look at your isVirtualPointerEvent implementation to trick it
You need presure or width/height to trick the method into working
await button.dispatchEvent("pointerdown", {
pressure: 1,
width: 5,
height: 5,
pointerType: "mouse",
});
await page.waitForTimeout(1000);
await button.dispatchEvent("pointerup", {
pressure: 1,
width: 5,
height: 5,
pointerType: "mouse",
});
adding force:1
is the key difference here, but this code is horrible and doesn't feel like an acceptable work around
Provide a general summary of the issue here
You cannot long press with playwright and useLongPress from react-aria. This happens because the pointerType is coming through as "virtual" usePress works but of course click type comes in as virtual
This issue also happens in jsdom too because of virtual events but other hacks required in that environment too.
π€ Expected Behavior?
Long press works with automation tools
π― Current Behavior
Long press does not work because virtual clicks are not supported.
π Possible Solution
It fails due to this line: https://github.com/adobe/react-spectrum/blob/e37ad74f5677475f36bab2998bc3285a10a8549b/packages/%40react-aria/interactions/src/useLongPress.ts#L73C1-L74C1 and this line https://github.com/adobe/react-spectrum/blob/e37ad74f5677475f36bab2998bc3285a10a8549b/packages/%40react-aria/interactions/src/useLongPress.ts#L115
And caused by
isVirtualPointerEvent
in your code detecting this as a virtual ponterπ¦ Context
Important functionality cannot be integrated or end to end tested without using keyboard instead
π₯οΈ Steps to Reproduce
Install playwright and use this test with
npx playwright test
see that i am using your docs site
Version
latest
What browsers are you seeing the problem on?
Chrome
If other, please specify.
Chromium in playwright
What operating system are you using?
Mac OS
π§’ Your Company/Team
No response
π· Tracking Issue
No response