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.

`.click()` doesn't fire `mouseout` event if element is obscured

See original GitHub issue

Current behavior:

In v3.5 a click() action also triggers the mouseover and mouseout events. However, if the element becomes obscured (for example hidden behind a dialog) due to the .click() action the mouseout event is never fired. In some cases, this can leave the UI in a state that will cause later tests to fail.

Note: A workaround is to use .click().trigger('mouseout', { 'force': true }).

Desired behavior:

The mouseout event should trigger if the element becomes obscured… in other words the user can no longer hover. This is the behavior I see in the native browser.

Steps to reproduce: (app code and test code)

  • A button contains a tooltip that obscures another button
  • Clicking on the first button causes a dialog to be shown for 1s.

See: https://github.com/Hypercubed/cypress-test-tiny/blob/5080e0943eb91a5da7c57b34e91f19a7ae8fab07/cypress/integration/spec.js

You will see that in v3.5 (but not v3.4 or native chrome) the tooltip remains even after the dialog opens and obscures the button.

image

Versions

v3.5

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:19 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
Hypercubedcommented, Oct 29, 2019

I’m using .trigger('mouseout', { 'force': true }) in a few places. I still think it would be useful to add an option to not send the additional mouse events.

0reactions
gabberseppcommented, Aug 25, 2020

I will try this hack to avoid an error in cypress. Jquery won’t report an error if no element was found so maybe this will help us here:

.get(locator).click({force: true}).then($e => $e.mouseout()))
Read more comments on GitHub >

github_iconTop Results From Across the Web

Click event prevents mouseout from triggering - Stack Overflow
When you click on lets say the About tab and hover over and out on contact the content should be hidden. But you...
Read more >
Element: mouseout event - Web APIs | MDN
The mouseout event is fired at an Element when a pointing device (usually a mouse) is used to move the cursor so that...
Read more >
Moving the mouse: mouseover/out, mouseenter/leave
The mouseover event occurs when a mouse pointer comes over an element, and mouseout – when it leaves. These events are special, because...
Read more >
hover - Cypress Documentation
Sometimes an element has specific logic on hover and you do need to "hover" in Cypress. Maybe the element doesn't even display to...
Read more >
onmouseleave Event - W3Schools
The onmouseleave event occurs when the mouse pointer leaves an element. The onmouseleave event is often used together with the onmouseenter event, which...
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