question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

visible button in a sticky element in a modal is detected as not visible

See original GitHub issue

Current behavior

I have a button inside a sticky element in a modal. Behind the modal is a scrollable element which is an ancestor of the modal. Cypress thinks that the button is not visible. I get the following error message:

This element <button#button> is not visible because its content is being clipped by one of its parent elements, which has a CSS property of overflow: hidden, scroll or auto

Here is the screenshot of the failing test: page -- works (failed)

Desired behavior

I can see the button. Cypress should recognize that it is visible.

Test code to reproduce

I have a simple example which reproduces this error. You can find it here: https://github.com/FraKraBa/cypress-test-tiny

Versions

Cypress 6.4.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
bahmutovcommented, Apr 7, 2021

Released in v7.0.0

1reaction
FraKraBacommented, Feb 8, 2021

I debugged a little bit and found the following suspicious function:

const elOrAncestorIsFixed = function ($el) {
    const $stickyOrFixedEl = $elements.getFirstFixedOrStickyPositionParent($el);

    if ($stickyOrFixedEl) {
       return $stickyOrFixedEl.css('position') === 'fixed'; // we are sticky => returns false
    }
};

In the case presented the button is inside a sticky element. Thus, elOrAncestorIsFixed returns false. Afterwards elIsOutOfBoundsOfAncestorsOverflow is called and tells that the button is not inside its ancestor Details which has overflow:scroll. However, between the button and Details is the modal which hat the property position:fixed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap modal not displaying
If you're running Bootstrap 4, it may be due to ".fade:not(.show) ... my modal was not showing, and I realized that my button...
Read more >
How to Fix Issues With CSS Position Sticky Not Working?
Learn possible reasons why CSS position sticky might not be working for you.
Read more >
Sticky side button and hide/show on hero image - Support
Hi, To fix this, kindly do the following. z-index: 9999; Add the code below in the style field of the Row Element where...
Read more >
overflow - CSS: Cascading Style Sheets - MDN Web Docs
Overflow options include clipping, showing scrollbars, or displaying the content flowing out of its container into the surrounding area.
Read more >
Modal · Bootstrap v5.0
Modals use position: fixed , which can sometimes be a bit particular about its rendering. Whenever possible, place your modal HTML in a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found