Skip to content

Commit

Permalink
fix: drag and click (#8331)
Browse files Browse the repository at this point in the history
<!--
Thank you for your contribution.

Before making a PR, please read our contributing guidelines at

https://github.com/DevExpress/testcafe/blob/master/CONTRIBUTING.md#code-contribution

We recommend creating a *draft* PR, so that you can mark it as 'ready
for review' when you are done.
-->

## Purpose
_Describe the problem you want to address or the feature you want to
implement._

## Approach
_Describe how your changes address the issue or implement the desired
functionality in as much detail as possible._

## References
closes #8250

## Pre-Merge TODO
- [ ] Write tests for your proposed changes
- [ ] Make sure that existing tests do not fail

---------

Co-authored-by: Bayheck <[email protected]>
  • Loading branch information
Bayheck and Bayheck authored Nov 20, 2024
1 parent 3dbb90b commit ef60584
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/client/automation/playback/drag/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default class DragAutomationBase extends VisibleElementAutomation {
});
}

_mouseup () {
_mouseup (draggedElement) {
return cursor
.buttonUp()
.then(() => {
Expand Down Expand Up @@ -126,7 +126,7 @@ export default class DragAutomationBase extends VisibleElementAutomation {
})
.then(element => {
//B231323
if (topElement && element === topElement && !this.dragAndDropState.enabled)
if (topElement && element === topElement && !this.dragAndDropState.enabled && element === draggedElement)
eventSimulator.click(topElement, options);
});
});
Expand All @@ -152,6 +152,6 @@ export default class DragAutomationBase extends VisibleElementAutomation {
return Promise.all([delay(this.automationSettings.mouseActionStepDelay), this._mousedown(eventArgs)]);
})
.then(() => this._drag())
.then(() => this._mouseup());
.then(() => this._mouseup(eventArgs.element));
}
}
11 changes: 11 additions & 0 deletions test/functional/fixtures/regression/gh-8250/pages/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>gh-8250</title>
</head>
<body>
<h1>Example</h1>
<input id="example" type="radio" />
</body>
</html>
5 changes: 5 additions & 0 deletions test/functional/fixtures/regression/gh-8250/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('[Regression](GH-8250)', function () {
it('Click should not be called after dragToElement', function () {
return runTests('testcafe-fixtures/index.js', 'Click should not be called', { only: 'chrome' });
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Selector } from 'testcafe';

fixture('GH-8250- Click should not be called after dragToElement')
.page`http://localhost:3000/fixtures/regression/gh-8250/pages/index.html`;

test('Click should not be called', async t => {
const h1Label = Selector('h1').withText('Example');
const radioInput = Selector('#example');

await t.dragToElement(h1Label, radioInput);
await t.expect(radioInput.checked).eql(false);
});

0 comments on commit ef60584

Please sign in to comment.