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

waitForAnimations false does not narrow down element to one at coordinates #14370

Closed
lukeapage opened this issue Dec 31, 2020 · 2 comments · Fixed by #14373
Closed

waitForAnimations false does not narrow down element to one at coordinates #14370

lukeapage opened this issue Dec 31, 2020 · 2 comments · Fixed by #14373

Comments

@lukeapage
Copy link
Contributor

lukeapage commented Dec 31, 2020

Current behavior

Say we have the following dom elements:

<div id="outer">
  <div id="inner">content</div>
</div>

and inner is taking up 100% of the outer container.

When calling

cy.get('#outer').click();

Cypress will actually call click on #inner as that is the element at the click point.

But if I do

cy.get('#outer').click({ waitForAnimations: false });

Then the dispatch happens on the outer element.

You can see clearly why in the code here:

// if force is true OR waitForAnimations is false
// then do not perform these additional ensures...
if ((options.ensure.notAnimating) && (force !== true) && (options.waitForAnimations !== false)) {
// store the coords that were absolute
// from the window or from the viewport for sticky elements
// (see https://github.com/cypress-io/cypress/pull/1478)
const sticky = !!getStickyEl($el)
coordsHistory.push(sticky ? coords.fromElViewport : coords.fromElWindow)
// then we ensure the element isnt animating
ensureNotAnimating(cy, $el, coordsHistory, options.animationDistanceThreshold)
// now that we know our element isn't animating its time
// to figure out if it's being covered by another element.
// this calculation is relative from the viewport so we
// only care about fromElViewport coords
$elAtCoords = options.ensure.notCovered && ensureElIsNotCovered(cy, win, $el, coords.fromElViewport, options, _log, onScroll)

Desired behavior

waitForAnimations: false should only change whether cypress waits for a animation, not whether cypress narrows down the element to fire events on.

Please let me know if you agree with this change in behaviour - I could make a PR that adds a test and changes the line above to continue to be omitted if force: true but to be run regardless of waitForAnimations

@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Dec 31, 2020
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Jan 6, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jan 6, 2021

The code for this is done in cypress-io/cypress#14373, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jan 20, 2021

Released in 6.3.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v6.3.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jan 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant