diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index 0b7c0a66b95e..6db21039841b 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -46,6 +46,7 @@ in this [GitHub issue](https://github.com/cypress-io/cypress/issues/30447). Addr - Elements with `display: contents` will no longer use box model calculations for visibility, and correctly show as visible when it is visible. Fixed in [#29680](https://github.com/cypress-io/cypress/pull/29680). Fixes [#29605](https://github.com/cypress-io/cypress/issues/29605). - The CSS pseudo-class `:dir()` is now supported when testing in Electron. Addresses [#29766](https://github.com/cypress-io/cypress/issues/29766). +- Elements whose parent elements has `overflow: clip` and no height/width will now correctly show as hidden. Fixed in [#29778](https://github.com/cypress-io/cypress/pull/29778). Fixes [#23852](https://github.com/cypress-io/cypress/issues/23852). **Dependency Updates:** diff --git a/packages/driver/cypress/e2e/dom/visibility.cy.ts b/packages/driver/cypress/e2e/dom/visibility.cy.ts index fe82cfb0bd02..e894fa233460 100644 --- a/packages/driver/cypress/e2e/dom/visibility.cy.ts +++ b/packages/driver/cypress/e2e/dom/visibility.cy.ts @@ -2,6 +2,14 @@ const { $, dom } = Cypress describe('src/cypress/dom/visibility', () => { + const add = (el) => { + return $(el).appendTo(cy.$$('body')) + } + + const reasonIs = ($el, str) => { + expect(dom.getReasonIsHidden($el)).to.eq(str) + } + beforeEach(() => { cy.visit('/fixtures/generic.html') }) @@ -163,10 +171,6 @@ describe('src/cypress/dom/visibility', () => { context('hidden/visible overrides', () => { beforeEach(function () { - const add = (el) => { - return $(el).appendTo(cy.$$('body')) - } - // ensure all tests run against a scrollable window const scrollThisIntoView = add('
Should be in view
') @@ -908,6 +912,23 @@ describe('src/cypress/dom/visibility', () => { expect(this.$elInParentBounds.find('span')).to.be.visible }) + it('is hidden when parent overflow clip and height is 0', function () { + cy.$$('body').empty() + + const el = add('
I am not visible
') + + expect(el.find('#hidden')).to.be.hidden + reasonIs(el.find('#hidden'), 'This element `` is not visible because its content is being clipped by one of its parent elements, which has a CSS property of overflow: `hidden`, `clip`, `scroll` or `auto`') + }) + + it('is visible when parent overflow clip and height is non-0', function () { + cy.$$('body').empty() + + const el = add('
I am visible
') + + expect(el.find('#visible')).to.be.visible + }) + it('is visible when ancestor is overflow hidden but more distant ancestor is the offset parent', function () { expect(this.$elIsOutOfBoundsOfAncestorsOverflowButWithinRelativeAncestor.find('span')).to.be.visible }) @@ -937,10 +958,6 @@ describe('src/cypress/dom/visibility', () => { }) describe('css transform', () => { - const add = (el) => { - return $(el).appendTo(cy.$$('body')) - } - describe('element visibility by css transform', () => { it('is visible when an element is translated a bit', () => { const el = add(`
Translated
`) @@ -1129,78 +1146,72 @@ describe('src/cypress/dom/visibility', () => { }) describe('#getReasonIsHidden', () => { - beforeEach(function () { - this.reasonIs = ($el, str) => { - expect(dom.getReasonIsHidden($el)).to.eq(str) - } - }) - it('has `display: none`', function () { - this.reasonIs(this.$displayNone, 'This element `