Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update visibility to support parent overflow:clip without height/width #29778

Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b1ea598
fix for 23852
senpl Jul 1, 2024
c3e1f49
changelog update
senpl Jul 1, 2024
3367369
changelog update
senpl Jul 1, 2024
0c6f4e5
fix reason of hide for compatibility
senpl Jul 1, 2024
3ace4ba
add clip to overflow props
senpl Jul 1, 2024
1988b2c
hide reason update message update
senpl Jul 1, 2024
51ce60c
clip fix no longer that general coz of firefox
senpl Jul 3, 2024
66a21ec
Merge branch 'develop' into issue-23852-ChildVisibleWithOverflowClip
senpl Jul 3, 2024
cb458f2
changelog update
senpl Jul 3, 2024
cfd928d
Merge branch 'develop' into issue-23852-ChildVisibleWithOverflowClip
jennifer-shehane Jul 3, 2024
6d9a3ee
Merge branch 'develop' into issue-23852-ChildVisibleWithOverflowClip
senpl Jul 8, 2024
354e709
Merge branch 'develop' into issue-23852-ChildVisibleWithOverflowClip
jennifer-shehane Jul 9, 2024
228c24e
Merge branch 'develop' into issue-23852-ChildVisibleWithOverflowClip
senpl Jul 12, 2024
a187a4f
Merge branch 'develop' into issue-23852-ChildVisibleWithOverflowClip
senpl Jul 25, 2024
290603f
Merge branch 'develop' into issue-23852-ChildVisibleWithOverflowClip
senpl Jul 26, 2024
1dee90a
Merge branch 'develop' into issue-23852-ChildVisibleWithOverflowClip
senpl Aug 7, 2024
fb247d9
Merge branch 'develop' into issue-23852-ChildVisibleWithOverflowClip
senpl Aug 8, 2024
8dd9881
Merge branch 'develop' into issue-23852-ChildVisibleWithOverflowClip
senpl Aug 12, 2024
d0f4c81
Merge branch 'develop' into issue-23852-ChildVisibleWithOverflowClip
senpl Aug 16, 2024
3a1c49d
Merge branch 'develop' into issue-23852-ChildVisibleWithOverflowClip
senpl Sep 30, 2024
a5ad68d
Merge branch 'release/14.0.0' into issue-23852-ChildVisibleWithOverfl…
senpl Oct 1, 2024
5d1923c
Merge branch 'release/14.0.0' into issue-23852-ChildVisibleWithOverfl…
senpl Oct 28, 2024
da150a3
Merge branch 'release/14.0.0' into issue-23852-ChildVisibleWithOverfl…
jennifer-shehane Oct 29, 2024
d3a779c
Merge branch 'release/14.0.0' into issue-23852-ChildVisibleWithOverfl…
senpl Oct 30, 2024
2e03ee1
pipeline changelog fixes
senpl Oct 30, 2024
e2258cb
Merge branch 'release/14.0.0' into issue-23852-ChildVisibleWithOverfl…
senpl Oct 30, 2024
669b4b7
Merge branch 'release/14.0.0' into issue-23852-ChildVisibleWithOverfl…
mschile Nov 19, 2024
53bd619
update OVERFLOW_PROPS
mschile Nov 19, 2024
0249bfc
update changelog
mschile Nov 19, 2024
8d919ba
Merge branch 'release/14.0.0' into issue-23852-ChildVisibleWithOverfl…
mschile Nov 26, 2024
e9272eb
fix firefox failure
mschile Nov 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ _Released 7/02/2024 (PENDING)_

- Fixed an issue where Chrome launch instances would not recreate the browser CRI client correctly after recovering from an unexpected browser closure. Fixes [#27657](https://github.com/cypress-io/cypress/issues/27657). Fixed in [#29663](https://github.com/cypress-io/cypress/pull/29663).
- Fixed an issue where Firefox 129 (Firefox Nightly) would not launch with Cypress. Fixes [#29713](https://github.com/cypress-io/cypress/issues/29713). Fixed in [#29720](https://github.com/cypress-io/cypress/pull/29720).
- Fixed an issue where overflow: clip in parent html node make child node visibility not correctly detected. Fixes [#23852](https://github.com/cypress-io/cypress/issues/23852). Fixed in [#29778](https://github.com/cypress-io/cypress/pull/29778).

**Dependency Updates:**

Expand Down
2 changes: 1 addition & 1 deletion packages/driver/cypress/e2e/dom/visibility.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ describe('src/cypress/dom/visibility', () => {
})

it('has a parent with an effective zero width and overflow: hidden', function () {
this.reasonIs(this.$parentNoHeight.find('span'), 'This element `<span>` is not visible because its parent `<div>` has CSS property: `overflow: hidden` and an effective width and height of: `100 x 0` pixels.')
this.reasonIs(this.$parentNoHeight.find('span'), 'This element `<span>` is not visible because its parent `<div>` has CSS property: `overflow: hidden` or `overflow: clip` and an effective width and height of: `100 x 0` pixels.')
})

it('element sits outside boundaries of parent with overflow clipping', function () {
Expand Down
12 changes: 12 additions & 0 deletions packages/driver/cypress/e2e/issues/23852.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// https://github.com/cypress-io/cypress/issues/23852
describe('issue visible element with parent 0 width are detected as not visible', () => {
before(() => {
cy
.viewport('macbook-16')
.visit('/fixtures/issue-23852.html')
})

it('can click element when effective 0 width parent used', () => {
expect(cy.$$('#hidden')).to.not.be.visible
})
})
4 changes: 4 additions & 0 deletions packages/driver/cypress/fixtures/issue-23852.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<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>
17 changes: 12 additions & 5 deletions packages/driver/src/dom/visibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { isElement, isBody, isHTML, isOption, isOptgroup, getParent, getFirstPare

const fixedOrAbsoluteRe = /(fixed|absolute)/

const OVERFLOW_PROPS = ['hidden', 'scroll', 'auto']
const OVERFLOW_PROPS = ['hidden', 'scroll', 'auto', 'clip']

const isVisible = (el) => {
return !isHidden(el, 'isVisible()')
Expand Down Expand Up @@ -193,6 +193,12 @@ const elHasDisplayInline = ($el) => {
return $el.css('display') === 'inline'
}

const elHasOverflowClip = function ($el) {
const cssOverflow = [$el.css('overflow'), $el.css('overflow-y'), $el.css('overflow-x')]

return cssOverflow.includes('clip')
}

const elHasOverflowHidden = function ($el) {
const cssOverflow = [$el.css('overflow'), $el.css('overflow-y'), $el.css('overflow-x')]

Expand Down Expand Up @@ -370,7 +376,8 @@ const elIsHiddenByAncestors = function ($el, checkOpacity, $origEl = $el) {
return true
}

if (elHasOverflowHidden($parent) && elHasNoEffectiveWidthOrHeight($parent)) {
if ((elHasOverflowHidden($parent) || elHasOverflowClip($parent))
&& elHasNoEffectiveWidthOrHeight($parent)) {
// if any of the elements between the parent and origEl
// have fixed or position absolute
return !elDescendentsHavePositionFixedOrAbsolute($parent, $origEl)
Expand All @@ -386,8 +393,8 @@ const parentHasNoOffsetWidthOrHeightAndOverflowHidden = function ($el) {
return false
}

// if we have overflow hidden and no effective width or height
if (elHasOverflowHidden($el) && elHasNoEffectiveWidthOrHeight($el)) {
// if we have overflow hidden or clip and no effective width or height
if ((elHasOverflowHidden($el) || elHasOverflowClip($el)) && elHasNoEffectiveWidthOrHeight($el)) {
return $el
}

Expand Down Expand Up @@ -532,7 +539,7 @@ export const getReasonIsHidden = function ($el, options = { checkOpacity: true }
width = elOffsetWidth($parent)
height = elOffsetHeight($parent)

return `This element \`${node}\` is not visible because its parent \`${parentNode}\` has CSS property: \`overflow: hidden\` and an effective width and height of: \`${width} x ${height}\` pixels.`
return `This element \`${node}\` is not visible because its parent \`${parentNode}\` has CSS property: \`overflow: hidden\` or \`overflow: clip\` and an effective width and height of: \`${width} x ${height}\` pixels.`
}

// nested else --___________--
Expand Down