Bug 140596 - UI Events: Focus event sequence incorrect
Summary: UI Events: Focus event sequence incorrect
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: UI Events (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Nobody
URL: https://w3c.github.io/uievents/#event...
Keywords: HasReduction, W3CTest
Depends on:
Blocks:
 
Reported: 2015-01-18 11:46 PST by Rodney Rehm
Modified: 2022-08-06 15:15 PDT (History)
4 users (show)

See Also:


Attachments
focus-event-sequence.html (1.88 KB, text/html)
2015-01-18 11:46 PST, Rodney Rehm
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rodney Rehm 2015-01-18 11:46:02 PST
Created attachment 244864 [details]
focus-event-sequence.html

# Steps to reproduce the problem:
1. register event listeners for focusout, blur, focusin, focus
2. observe sequence of dispatched events upon shifting focus

Live test-case: http://medialize.github.io/ally.js/tests/browser-bugs/focus-event-order.html


# What is the expected behavior?
The sequence per DOM Level 3 [1] should be: focusout, focusin, blur, focus

[1] https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#events-focusevent-event-order


# What went wrong?
sequence is blur, focusout, focus, focusing


With the currently provided sequence the focusout and focusin events cannot be safely used to alter focus before it was given. The only "benefit" the current implementation brings with focusin over focus is that the former bubbles, the latter does not.

Gecko doesn't support focusin/focusout at all. WebKit suffers the same bug. IE11 dispatches focus events asynchronously thereby accidentally getting the sequence right, IE12 Win10 Tec Preview fixed the ansynchronous-bug and thereby messed up the sequence as well.

Chromium bug for reference: https://code.google.com/p/chromium/issues/detail?id=449857
Comment 1 Chris Rebert 2016-05-26 13:17:32 PDT
Another testcase: http://w3c-test.org/uievents/order-of-events/focus-events/focus-manual.html
Comment 2 Ahmad Saleem 2022-08-06 15:15:36 PDT
We pass following WPT tests - https://wpt.fyi/results/uievents/order-of-events/focus-events/focus-automated-blink-webkit.html?label=master&label=experimental&aligned&view=subtest&q=focus-event

Which are in relation to "order of event" similar to Comment 01.

I am going to mark this as "RESOLVED CONFIGURATION CHANGED", since we are passing related WPT tests. Please reopen, if I am wrong. Thanks!