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.

Focusout event not triggered when test window is not focused

See original GitHub issue

So, I have a simple Ember component input which has the built-in focusOut Ember event. In an integration test, using ember-test-helpers triggerEvent(input, 'blur') on this input or fillIn(other-input, 'blbl') in another input does not trigger the focusOut event if the window test is not focused while running.

I created a new Ember project to demonstrate this bug (see tests/integration/my-component-test.js), you can check it out here => test-focusout

How to test

  1. ember t -s --filter='Integration | Component | my-component'
  2. Open dev tools in test window.
  3. Click in console and refresh page (click inside test window if you want to re-focusin).
  4. Same behaviour when running the test while focusing another window. Reproduced on Chrome 76.0.3809.87 and Firefox 68.0.1

Is that the expected behaviour ?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:16 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
rwjbluecommented, Apr 22, 2020

Lets do it!

1reaction
rwjbluecommented, Apr 22, 2020

You are suggesting that we would effectively to do:

if (document.activeElement) { 
  await blur(document.activeElement);
}

Inside fillIn / typeIn / click?

Read more comments on GitHub >

github_iconTop Results From Across the Web

focusout() or blur() not triggered with popup
You can't get any focus events for normal divs. You can manually check if mouse clicked outside that popup: document.body.
Read more >
Element: focusout event - Web APIs | MDN
The opposite of focusout is the focusin event, which fires when the element has received focus. The focusout event is not cancelable.
Read more >
onfocus Event
Definition and Usage. The onfocus event occurs when an element gets focus. The onfocus event is often used on input fields.
Read more >
.focus() | jQuery API Documentation
A function to execute each time the event is triggered. version added: 1.0.focus(). This signature does not accept any arguments.
Read more >
blur and focus - Events
blur and focus ; Window + focusable element. If the window is sent backward while a focusable element is focused, blur events should...
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