click() has side effect of moving DOM elements vertically within non-scrollable container #9739
Description
Current behavior
Applying a .click() to an element can in some situations result in the page layout changing in that a containing element of the click target moves vertically.
In this case, we have a simple page rendered by React with a page root (green border) and a div (yellow border) with
height: 100%
position: fixed;
padding-top: 60px;
The padding leaves space for some top nav (light grey)
Inside this container there is some content, (red border) which is set to
height: 100%
I.e. it fills the remaining viewport space (apart from the padding) and therefore is positioned 60px from viewport top. All is well:
Then, we apply a Cypress click to the button element, and:
- the padding is no longer obeyed - the red element moves UP
- the click then fails as the center of the button has moved behind the header
DOM inspection shows that the padding still exists, no attributes of the key elements appear to have changed.
It has been captured by the Cypress screenshots, it's clear to see that it is the click() that causes the move.
Inserting a pause() or wait() before the click means that no movement is seen until the click is called.
Clicking other elements also has the same effect.
Desired behavior
No side-effects on click.
Needless to say, a real click does not have this effect, neither does the app ever exhibit this behavior in real life, only in Cypress.
Test code to reproduce
This will take quite some effort to strip down but can be done if the above does not give any "aha" ideas, or private access can be given to a repo.
Versions
Cypress 6.1.0 and many past versions at least to 3.x.x (this has been a problem for a while)
Electron, Firefox and Chrome browser with Cypress.