Skip to content

Commit

Permalink
fix: inline element with visibile child now is considered visible (#8130
Browse files Browse the repository at this point in the history
)
  • Loading branch information
panzarino committed Aug 17, 2020
1 parent 9a32862 commit 4c8fb2f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/driver/cypress/integration/dom/visibility_spec.ts
Expand Up @@ -308,6 +308,14 @@ describe('src/cypress/dom/visibility', () => {
<span style="position: fixed; top: 40px;">parent pointer-events: none</span>
</div>
<span style="position: fixed; top: 40px; background: red;">covering the element with pointer-events: none</span>\
`)

this.$parentDisplayInlineChildDisplayBlock = add(`\
<div>
<span>
<label style="display: block;">display: block</label>
</span>
</div>\
`)

this.$elOutOfParentBoundsToLeft = add(`\
Expand Down Expand Up @@ -738,6 +746,14 @@ describe('src/cypress/dom/visibility', () => {
})
})

describe('css display', function () {
// https://github.com/cypress-io/cypress/issues/6183
it('parent is visible if display inline and child has display block', function () {
expect(this.$parentDisplayInlineChildDisplayBlock.find('span')).to.be.visible
expect(this.$parentDisplayInlineChildDisplayBlock.find('span')).to.not.be.hidden
})
})

describe('css overflow', () => {
it('is visible when parent doesnt have overflow hidden', function () {
expect(this.$parentNoWidthHeightOverflowAuto.find('span')).to.be.visible
Expand Down
15 changes: 15 additions & 0 deletions packages/driver/src/dom/visibility.js
Expand Up @@ -52,6 +52,11 @@ const isHidden = (el, name = 'isHidden()') => {
// either its offsetHeight or offsetWidth is 0 because
// it is impossible for the user to interact with this element
if (elHasNoEffectiveWidthOrHeight($el)) {
// https://github.com/cypress-io/cypress/issues/6183
if (elHasDisplayInline($el)) {
return !elHasVisibleChild($el)
}

return true // is hidden
}

Expand Down Expand Up @@ -152,6 +157,10 @@ const elHasDisplayNone = ($el) => {
return $el.css('display') === 'none'
}

const elHasDisplayInline = ($el) => {
return $el.css('display') === 'inline'
}

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

Expand Down Expand Up @@ -230,6 +239,12 @@ const elDescendentsHavePositionFixedOrAbsolute = function ($parent, $child) {
})
}

const elHasVisibleChild = function ($el) {
return _.some($el.children(), (el) => {
return isVisible(el)
})
}

const elIsNotElementFromPoint = function ($el) {
// if we have a fixed position element that means
// it is fixed 'relative' to the viewport which means
Expand Down

3 comments on commit 4c8fb2f

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 4c8fb2f Aug 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.0/linux-x64/circle-develop-4c8fb2fd5e8580b0cd43a3b89f5eb76f606d2fb4-423473/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.0/circle-develop-4c8fb2fd5e8580b0cd43a3b89f5eb76f606d2fb4-423460/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 4c8fb2f Aug 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.0/win32-x64/appveyor-develop-4c8fb2fd5e8580b0cd43a3b89f5eb76f606d2fb4-34690205/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-4c8fb2fd5e8580b0cd43a3b89f5eb76f606d2fb4-34690205/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/5.0.0/win32-x64/appveyor-develop-4c8fb2fd5e8580b0cd43a3b89f5eb76f606d2fb4-34690205/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-4c8fb2fd5e8580b0cd43a3b89f5eb76f606d2fb4-34690205/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.0/win32-x64/appveyor-develop-4c8fb2fd5e8580b0cd43a3b89f5eb76f606d2fb4-34690205/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-4c8fb2fd5e8580b0cd43a3b89f5eb76f606d2fb4-34690205/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.0/win32-x64/appveyor-develop-4c8fb2fd5e8580b0cd43a3b89f5eb76f606d2fb4-34690205/cypress.zip npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-4c8fb2fd5e8580b0cd43a3b89f5eb76f606d2fb4-34690205/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 4c8fb2f Aug 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.0/win32-ia32/appveyor-develop-4c8fb2fd5e8580b0cd43a3b89f5eb76f606d2fb4-34690205/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-4c8fb2fd5e8580b0cd43a3b89f5eb76f606d2fb4-34690205/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/5.0.0/win32-ia32/appveyor-develop-4c8fb2fd5e8580b0cd43a3b89f5eb76f606d2fb4-34690205/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-4c8fb2fd5e8580b0cd43a3b89f5eb76f606d2fb4-34690205/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.0/win32-ia32/appveyor-develop-4c8fb2fd5e8580b0cd43a3b89f5eb76f606d2fb4-34690205/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-4c8fb2fd5e8580b0cd43a3b89f5eb76f606d2fb4-34690205/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.0/win32-ia32/appveyor-develop-4c8fb2fd5e8580b0cd43a3b89f5eb76f606d2fb4-34690205/cypress.zip npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-4c8fb2fd5e8580b0cd43a3b89f5eb76f606d2fb4-34690205/cypress.tgz

Please sign in to comment.