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
Add drag-and-drop support. #7150
Conversation
Hello! I've been trying to test drag-and-drop at work using a variety of E2E tools like Cypress and Webdriver. Unfortunately like everyone else I kept running into a frustrating issue where the thing getting dragged would just stick to my mouse cursor instead of getting dropped at a given location. Luckily, it turns out that Chromium recently added some new hooks for dragging and I'm happy to report they work great! I know this PR is a bit light on the tests, but I wanted to make sure this was going in the right direction before I spent more time. Looking forward to your feedback, thanks! |
test/drag-and-drop.spec.ts
Outdated
@@ -0,0 +1,47 @@ | |||
/** | |||
* Copyright 2018 Google Inc. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Copyright 2018 Google Inc. All rights reserved. | |
* Copyright 2021 Google Inc. All rights reserved. |
@jschfflr Could you PTAL (and consider the record/replay perspective)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all, the general direction of this change looks good to me. Thanks for taking the time to create this patch!
I just have some small questions:
I'm not sure why you chose to create a new CDP Session for the drag events - could you elaborate on that or just use the already existing one?
Also, there is the optional modifiers
flag - could you make sure that the current set of modifiers from the keyboard is respected?
For the return value of the drag: WDYT about returning the DragData directly (instead of the event)?
Thanks @jschfflr for taking a look! Updated the PR based on your feedback. RE: This was for isolating the drag interception in case something else was also listening for drag events on the existing client. If this isn't a concern, I can use the existing client. On a different note, the |
Thanks for updating the patch! If you feel like the drop events would also be useful on their own, feel free to also expose them. |
Updated and moved the drag interception to the Page class; thanks for pointing me to that.
Makes total sense, will keep the drop method as is.
I think a |
e452082
to
b292ec0
Compare
Awesome, thanks! We do have the |
@danparksf Hi, did you already have time to look into the changes we discussed? |
Hi @jschfflr, thanks for the feedback! Been meaning to look into updating this PR and finally have some time to work on them. Should have an update later today, thanks! |
@jschfflr haven't added the |
@danparksf Yes, feel free to mark this function as public! |
Maybe you can also change the return type and expose a public |
abe50de
to
1385f56
Compare
Thanks for the tips, PR updated! |
@danparksf Not sure if you are already aware of this, but you can use |
Thanks, should be passing the lint check now. |
@danparksf Thanks! The linter is happy now. Could you also look into the failing unit tests? You can run them locally with |
This commit adds drag-and-drop support, leveraging new additions to the CDP Input domain (Input.setInterceptDrags, Input.dispatchDragEvent, and Input.dragIntercepted).
* Update date in test * Pass modifiers when dispatching drag events * Return DragData directly instead of event
* Moved drag interception code to Page * Added tests for drag interception enablement
* Add separate methods for dragEnter and dragOver * Fix lint errors * Add some docs for ElementHandle.drag() and Mouse.drag()
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
@googlebot I consent. |
@danparksf Awesome, let's get this landed then :) |
This commit adds drag-and-drop support, leveraging new additions to the CDP Input domain (Input.setInterceptDrags, Input.dispatchDragEvent, and Input.dragIntercepted).
@danparksf Congrats on getting this landed! |
Thanks @jschfflr for your help! |
Having it be a getter is surprising and inconsistent, since since the other `page.is*` APIs are just methods. Issue: #7150
Having it be a getter is surprising and inconsistent, since the other `page.is*` APIs are just methods. Issue: #7150
Having it be a getter is surprising and inconsistent, since the other `page.is*` APIs are just methods. Issue: #7150
Having it be a getter is surprising and inconsistent, since the other `page.is*` APIs are just methods. Issue: #7150
Having it be a getter is surprising and inconsistent, since the other `page.is*` APIs are just methods. Issue: #7150
This PR adds drag-and-drop support, leveraging new additions to the CDP Input domain (Input.setInterceptDrags, Input.dispatchDragEvent, and Input.dragIntercepted).
Fixes #1376