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
- Open this CodeSandbox: https://rvh87.csb.app/
- Click on “click with user-event” button
- You will see “blur” logs in the console
- Click on “test button” directly
- 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:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Updated the original comment
@ph-fritsche
I’ve put up a pull request to add @just-boris! 🎉