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 handler should not fire blur when the click target inside currently focused element

See original GitHub issue
  • @testing-library/user-event version: 7.29.6 (latest at the time of writing)

  • Testing Framework and version: n/a

  • DOM Environment: Tested in Chrome/Safari/Firefox

Steps to reproduce

  1. Open this CodeSandbox: https://rvh87.csb.app/
  2. Click on “click with user-event” button
  3. You will see “blur” logs in the console
  4. Click on “test button” directly
  5. There are no “blur” logs in the console

Code Example:

Codesanbox source: https://codesandbox.io/s/rvh87

<button class="to-test">
  <span>test button</span>
</button>
userEvent.click(screen.getByText("test button"));

Suggested solution:

The library should check if the click target is inside already focused container and should not blur it.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
just-boriscommented, Feb 28, 2021

Updated the original comment

0reactions
allcontributors[bot]commented, Feb 28, 2021

@ph-fritsche

I’ve put up a pull request to add @just-boris! 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

When a 'blur' event occurs, how can I find out which element ...
2015 answer: according to UI Events, you can use the relatedTarget property of the event: Used to identify a secondary EventTarget related to...
Read more >
Element: blur event - Web APIs | MDN
The blur event fires when an element has lost focus. The event does not bubble, but the related focusout event that follows does...
Read more >
Focusing: focus/blur - The Modern JavaScript Tutorial
The focus event is called on focusing, and blur – when the element loses the focus. Let's use them for validation of an...
Read more >
onblur Event - W3Schools
The onblur event occurs when an element loses focus. The onblur event is often used on input fields. The onblur event is often...
Read more >
Catching the blur event on an element and its children
Listen to a blur event on the parent element (in my case it was the menu). · In the handler, give browser time...
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