WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED WONTFIX
243749
blur and focusout are not fired on document.activeElements when they are removed from the dom
https://bugs.webkit.org/show_bug.cgi?id=243749
Summary
blur and focusout are not fired on document.activeElements when they are remo...
Rob Snow
Reported
2022-08-09 13:45:01 PDT
blur and focusout are not fired on document.activeElements when they are removed from the dom
https://jsfiddle.net/snowystinger/87os2az9/15/
When you run the fiddle in Safari, tab to the button and wait for the setTimeout to remove the button from the dom. I would expect focusout and blur listeners to be triggered. I don't expect them to bubble up the tree as they have been removed, but a direct listener on it should be called. This is also a bug in Firefox
https://bugzilla.mozilla.org/show_bug.cgi?id=559561
It works as expected in Chrome.
Attachments
Add attachment
proposed patch, testcase, etc.
Ryosuke Niwa
Comment 1
2022-08-10 18:38:03 PDT
This is the expected behavior.
Rob Snow
Comment 2
2022-08-11 11:57:22 PDT
Thanks for the quick reply. However, I would argue this is not good behavior. It makes it very difficult to track and manage focus. For example, if you have a focus scope that contains focus within it, you need to know when focus leaves it so you can move the focus back inside. A common example of this is a Dialog. Right now, a blur event is not fired when the active element is removed from the dom, nor is a focus event fired on the body. So it's impossible to tell that focus moved outside of the scope.
https://html.spec.whatwg.org/multipage/interaction.html#focusing-steps
I know this isn't specific about what happens when an active element becomes inert. However, I think it's reasonable to assume that an element becoming inert must lose focus. Therefore, it should go through the unfocusing steps, and then become inert. If this isn't the case, how would you recommend containing focus.
Rob Snow
Comment 3
2022-08-11 12:44:51 PDT
For more info in other browser engines, see
https://bugzilla.mozilla.org/show_bug.cgi?id=559561
As well as open issues in the living spec
https://github.com/whatwg/html/issues/1195
https://github.com/whatwg/html/issues/3162
https://github.com/jsdom/jsdom/issues/2931
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug