cypress icon indicating copy to clipboard operation
cypress copied to clipboard

Child is visible with Parent max-height: 0 and overflow: clip

Open tobdru opened this issue 3 years ago • 3 comments
trafficstars

Current behavior

If the parent has max-height: 0 and overflow: hidden/clip cypress interprets the child as visible.

Desired behavior

As the Element is hidden and never can be visible to the user the check '.should('not.be.visible')' should be truthy

Test code to reproduce

<div style="max-height: 0; overflow: clip;">
    <div data-cy="not-visible">
        I should not be visible
    </div>
</div>

cy.get('[data-cy="not-visible"]').should('not.be.visible');

Cypress Version

10.8.0

Node version

16.15.1

Operating System

Windows 10

Debug Logs

No response

Other

No response

tobdru avatar Sep 16 '22 12:09 tobdru

With the given html, the div is visible to the human eye:

Screen Shot 2022-09-19 at 8 50 12 AM

I believe that's because overflow: 'hidden' (with quotes around hidden) is not valid CSS.

Changing it to overflow: hidden (without quotes) causes it not be visible, but then the assertion .should('not.be.visible') also passes.

Screen Shot 2022-09-19 at 8 50 26 AM

Can you verify the assertion still fails for you if it's overflow: hidden?

chrisbreiding avatar Sep 19 '22 12:09 chrisbreiding

Oh sry i have rewritten it wrong out of my react example app and in addition i had the wrong state of the code.

Actually it is overflow:clip.

This is the actual rendered in the iframe by cypress (without quotes):

<body>
    <div id="root"><div style="max-height: 0px; overflow: clip;"><div id="hidden">I am not visible</div></div></div>
    <script type="module" src="/src/main.jsx"></script>
</body>

And this is displayed image

tobdru avatar Sep 19 '22 13:09 tobdru

Thanks for the quick reply.

I verified it's not working correctly with overflow: clip. I'll route this to a team to look into a fix.

chrisbreiding avatar Sep 19 '22 13:09 chrisbreiding