Draggable doesn't recognize MouseEvent and dont work with Playwright
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, playwright, typescript
- Domain
- frontend, testing-qa, web-dev
Research direction
Reproduce the issue with the two event-dispatch approaches and Playwright's page.mouse sequence described in the report. Trace Draggable's mouse-event handling to identify why a MouseEvent behaves differently, then verify that the supported approach works without TestUtils and that the Playwright drag sequence completes successfully.
Written by the indexing model from the issue text.
Description
For E2E we have to simulate DnD, and code
const triggerMouseEvent = (node: HTMLElement, eventType: string, data: { clientX: number; clientY: number }) => {
const evt = new MouseEvent(eventType, data);
node.dispatchEvent(evt);
};
triggerMouseEvent('mousedown', {clientX: 0, clientY: 0 });
triggerMouseEvent('mousemove', {clientX: 50, clientY: 0 });
triggerMouseEvent('mouseup', {clientX: 50, clientY: 0 });
Don't work, but
const triggerMouseEvent = (node: HTMLElement, eventType: string, data: { clientX: number; clientY: number }) => {
const evt = document.createEvent('MouseEvents');
evt.initMouseEvent(
eventType,
true,
true,
window,
0,
data.clientX,
data.clientY,
data.clientX,
data.clientY,
false,
false,
false,
false,
0,
null,
);
node.dispatchEvent(evt);
};
triggerMouseEvent('mousedown', {clientX: 0, clientY: 0 });
triggerMouseEvent('mousemove', {clientX: 50, clientY: 0 });
triggerMouseEvent('mouseup', {clientX: 50, clientY: 0 });
Seem to be works fine!
PS: I can't use TestUtils, because code above injected to the document via Playwright, and it should be 'clearable', without dependency links.
But! initMouseEvent is deprecated... and wanna have more actual solution
PS: The better if would work default playwright D'n'D code like
await page.mouse.move(x, y);
await page.mouse.down();
await page.mouse.move(x + deltaX, y + deltaY);
await page.mouse.up();
- Dominant language
- JavaScript
- Stars
- 9.3k
- Forks
- 1k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 4
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from react-grid-layout/react-draggable
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
react-grid-layout/react-draggable#784 · 4 comments · 2 reactions ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
react-grid-layout/react-draggable#782 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
react-grid-layout/react-draggable#781 · 1 comment · 2 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
react-grid-layout/react-draggable#780 · 8 comments ·
All issues in react-grid-layout/react-draggable
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sugarlabs/musicblocks#8847 ·