Skip to content

Commit 7db89d6

Browse files
committed
recalculate coords after "nudge" scroll
algorithm
1 parent 93d920a commit 7db89d6

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

packages/driver/src/cy/actionability.coffee

+4-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,10 @@ verify = (cy, $el, options, callbacks) ->
263263
$elAtCoords = ensureElIsNotCovered(cy, win, $el, coords.fromViewport, options, _log, onScroll)
264264

265265
## pass our final object into onReady
266-
return onReady($elAtCoords ? $el, coords)
266+
finalEl = $elAtCoords ? $el
267+
finalCoords = getCoordinatesForEl(cy, $el, options)
268+
269+
return onReady(finalEl, finalCoords)
267270

268271
## we cannot enforce async promises here because if our
269272
## element passes every single check, we MUST fire the event

packages/driver/test/cypress/integration/commands/actions/click_spec.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -743,9 +743,12 @@ describe('src/cy/commands/actions/click', function () {
743743
})
744744

745745
it('scrolls the window past a fixed position element when being covered', () => {
746+
const spy = cy.spy(_.noop).as('mousedown')
747+
746748
$('<button>button covered</button>')
747749
.attr('id', 'button-covered-in-nav')
748750
.appendTo(cy.$$('#fixed-nav-test'))
751+
.mousedown(spy)
749752

750753
$('<nav>nav on button</nav>').css({
751754
position: 'fixed',
@@ -762,11 +765,16 @@ describe('src/cy/commands/actions/click', function () {
762765
return scrolled.push(type)
763766
})
764767

765-
return cy.get('#button-covered-in-nav').click().then(() => {
768+
return cy.get('#button-covered-in-nav').click()
769+
.then(() => {
766770
// - element scrollIntoView
767771
// - element scrollIntoView (retry animation coords)
768772
// - window
769-
return expect(scrolled).to.deep.eq(['element', 'element', 'window'])
773+
expect(scrolled).to.deep.eq(['element', 'element', 'window'])
774+
expect(spy.args[0][0]).to.deep.include({
775+
clientX: 60,
776+
clientY: 68,
777+
})
770778
}
771779
)
772780
})

0 commit comments

Comments
 (0)