Skip to content

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

@lukeapage

Description

@lukeapage

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions