-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Figure out what to do with focusin/focusout #88
Comments
I don't know much about these events myself, but clearly fixing things to be interoperable one way or another is important. @dtapuska / @choniong thoughts? |
The ordering of the events focusout & blur, focusin & focus could be made whatever we want as long as they are in pairs. The spec indicates an intermixed scenario which we don't implement. The relevant code fires blur, focusout, DOMFocusOut and focus, focusin, DOMFocusIn. We should probably also look at making DOMFocusOut/DOMFocusIn as legacy event mappings for focusin/focusout so that an event target doesn't actually get both. |
Let's not talk about DOMFocusOut/In here, given that they are by all means deprecated. I tried to look for webkit bugs implementing focusin/out, but couldn't find the relevant one. That might have revealed why the behavior is so odd in webkit/blink. The whole point of focusout/in is that they happen before blur/focus, but apparently that isn't happening, so the use cases for focusout/in are very weak. |
So that just doesn't make much sense, since, as I said @dtapuska I assume blink won't be changing its behavior? Same question to @rniwa and @jacobrossi |
I'm open to fixing blink. I'd like to hear from the edge team before blink would move on this. I think I'd like to see what jquery needs and provide that so they don't need to polyfill it. |
@mgol ^ |
Adding @travisleithead. |
If we change blink, with the existing jQuery code continue to work or will it be broken by the change? |
I'm definitely in favor of interop, and I'd prefer to have the right (useful) event ordering here that makes the most sense. If we're going to change to a particular new ordering then it: should be done together (all implementations) and done with minimal web compatibility fallout.
Agree.
Good question. |
@travisleithead do you have any justification why the implementation changed between Edge and IE? I just want to understand if there were any interop concerns in this area. |
Looks like blink doesn't fire focusin/out on Window object, even though it does fire focus/blur. |
We discussed this issue in the jQuery core team meeting today and our recommendation is:
The only thing jQuery guarantees right now is that focusin happens before focus and focusout happens before blur. Only IE11 has a reliable way to detect the events so jQuery simulates them even when the browser has them, which would be bad except that nobody seems to implement them correctly anyway. Once there is a reliable feature detect jQuery can defer to the working browser implementation. |
focusin/out are not cancelable in the latest UIEvents spec. |
Another reason we like the spec order is related to something that's already been mentioned. We've had several tickets over the years about things like |
Also see current state of impl in browsers at jquery/jquery#3123 (comment) |
More weird stuff in blink. If focus is moved in blur handler, focusout it still dispatched, but if |
As of now I'm hoping to replicate most of blink's behavior in Gecko, since at least that behavior should be web compatible. But, since that model is quite odd, I'd be very happy if we all agreed to fix this and follow the model closer to what is in the current spec. Unfortunately I haven't seen much related implementation work happening in other browsers, so expectations in that aren't too high. |
@smaug---- I'd prefer that we actually shipped something that made sense. We have written interop tests here: web-platform-tests/wpt#3857 (from @sunyunjia) We were waiting on hearing back from jquery. But it appears they were expecting cancelable events for focusin/focusout. We are going to try to change our processing model this quarter but I'm not sure what monsters are lurking in the corners. |
Also, focus-y events should work properly even when the browser window isn't in focus, that would be a good thing to ensure. |
Perhaps you could provide a little bit of context - why it was decided to make |
It does seem like making them cancelable would be handy at times. Note that IE and Edge get focus management wrong when the focus leaves the window and actually prevent the user from even escaping to the browser chrome. |
@dtapuska any updates here? |
We (Chrome) want to do this work although it isn't clear what interop issues we will have so it has gotten low priority. Is there new problems that this would solve which justifies a bump in priority? |
@dtapuska basically, the longer we wait the less likely it becomes. It also would be good to have all focus events defined in detail to make sure that new platform features such as shadow roots interact well with them. |
Since my pull-request on uievents/order-of-events/focus-events/focus-manual.html in web-platform-tests is currently blocked because of this issue, I thought I'd chime in :) In my testing for that change and the accompanying change in the w3c html spec: it seems that most browsers have "naturally" converged on pretty much the same behavior which is reflected in my changes in the test. The current test only passes in IE and the behavior is not very intuitive imo. With my changes the test passes in Chrome, Firefox, Safari and almost in Edge. Since this seems to be the model the web has landed on I suggest changing the test rather than the implementers. |
I re-checked browser behavior. Edge 17 & newer now matches Chrome. Firefox implemented that order as well. All dispatch the events in the following order:
IE 11 follows the spec order, i.e.:
The test case checking native behavior: https://jsfiddle.net/66znLhfw/15/ Is this still realistic to change the order when all current browsers implemented the same non-standard order? |
I just hit this issue (again) and I'm curious where we stand. The spec still says:
...but Blink, Gecko, and WebKit all do this:
While the specified behavior makes much more sense to me, I think that horse has left the barn, and we should likely update the spec to match the behavior. Thoughts? |
The problem is described in [1]. While the spec says 'focusin' should come before 'focus', because that makes sense, implementations actually do the reverse, including Chromium. That means that developer event listeners on 'focus' can show or hide a pop-up, and that gets completed before the 'focusin' handler gets called. Then, when 'focusin' happens, the existing logic sees that focus is not in the (now showing) pop-up, decides that's a light dismiss signal, and hides the pop-up. From the developer's point of view, the pop-up never opened. With this new code, light dismiss is handled when the 'focus' event is fired, and if it isn't cancelled. [1] w3c/uievents#88 Bug: 1307772 Fixed: 1354293 Change-Id: I20373bcd8aeef24cddac5abd4548e9dc9428abf1
The problem is described in [1]. While the spec says 'focusin' should come before 'focus', because that makes sense, implementations actually do the reverse, including Chromium. That means that developer event listeners on 'focus' can show or hide a pop-up, and that gets completed before the 'focusin' handler gets called. Then, when 'focusin' happens, the existing logic sees that focus is not in the (now showing) pop-up, decides that's a light dismiss signal, and hides the pop-up. From the developer's point of view, the pop-up never opened. With this new code, light dismiss is handled when the 'focus' event is fired, and if it isn't cancelled. [1] w3c/uievents#88 Bug: 1307772 Fixed: 1354293 Change-Id: I20373bcd8aeef24cddac5abd4548e9dc9428abf1
The problem is described in [1]. While the spec says 'focusin' should come before 'focus', because that makes sense, implementations actually do the reverse, including Chromium. That means that developer event listeners on 'focus' can show or hide a pop-up, and that gets completed before the 'focusin' handler gets called. Then, when 'focusin' happens, the existing logic sees that focus is not in the (now showing) pop-up, decides that's a light dismiss signal, and hides the pop-up. From the developer's point of view, the pop-up never opened. With this new code, light dismiss is handled when the 'focus' event is fired, and if it isn't cancelled. [1] w3c/uievents#88 Bug: 1307772 Fixed: 1354293 Change-Id: I20373bcd8aeef24cddac5abd4548e9dc9428abf1
The problem is described in [1]. While the spec says 'focusin' should come before 'focus', because that makes sense, implementations actually do the reverse, including Chromium. That means that developer event listeners on 'focus' can show or hide a pop-up, and that gets completed before the 'focusin' handler gets called. Then, when 'focusin' happens, the existing logic sees that focus is not in the (now showing) pop-up, decides that's a light dismiss signal, and hides the pop-up. From the developer's point of view, the pop-up never opened. With this new code, light dismiss is handled when the 'focus' event is fired, and if it isn't cancelled. [1] w3c/uievents#88 Bug: 1307772 Fixed: 1354293 Change-Id: I20373bcd8aeef24cddac5abd4548e9dc9428abf1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3848846 Reviewed-by: David Baron <[email protected]> Commit-Queue: Mason Freed <[email protected]> Auto-Submit: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1038350}
The problem is described in [1]. While the spec says 'focusin' should come before 'focus', because that makes sense, implementations actually do the reverse, including Chromium. That means that developer event listeners on 'focus' can show or hide a pop-up, and that gets completed before the 'focusin' handler gets called. Then, when 'focusin' happens, the existing logic sees that focus is not in the (now showing) pop-up, decides that's a light dismiss signal, and hides the pop-up. From the developer's point of view, the pop-up never opened. With this new code, light dismiss is handled when the 'focus' event is fired, and if it isn't cancelled. [1] w3c/uievents#88 Bug: 1307772 Fixed: 1354293 Change-Id: I20373bcd8aeef24cddac5abd4548e9dc9428abf1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3848846 Reviewed-by: David Baron <[email protected]> Commit-Queue: Mason Freed <[email protected]> Auto-Submit: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1038350}
The problem is described in [1]. While the spec says 'focusin' should come before 'focus', because that makes sense, implementations actually do the reverse, including Chromium. That means that developer event listeners on 'focus' can show or hide a pop-up, and that gets completed before the 'focusin' handler gets called. Then, when 'focusin' happens, the existing logic sees that focus is not in the (now showing) pop-up, decides that's a light dismiss signal, and hides the pop-up. From the developer's point of view, the pop-up never opened. With this new code, light dismiss is handled when the 'focus' event is fired, and if it isn't cancelled. [1] w3c/uievents#88 Bug: 1307772 Fixed: 1354293 Change-Id: I20373bcd8aeef24cddac5abd4548e9dc9428abf1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3848846 Reviewed-by: David Baron <[email protected]> Commit-Queue: Mason Freed <[email protected]> Auto-Submit: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1038350}
I agree that we should specify what is implemented. And then if there is sufficient interest for a change a new proposal can be made for that and evaluated separately. Having said that, I suggest that we take this opportunity to define these events in the HTML Standard, where focus is already mostly defined anyway: whatwg/html#3514. |
I would be very surprised if this can be changed anymore, I mean from what has been shipping for years now. |
…'focusin' to 'focus', a=testonly Automatic update from web-platform-tests Move the focus-based light dismiss from 'focusin' to 'focus' The problem is described in [1]. While the spec says 'focusin' should come before 'focus', because that makes sense, implementations actually do the reverse, including Chromium. That means that developer event listeners on 'focus' can show or hide a pop-up, and that gets completed before the 'focusin' handler gets called. Then, when 'focusin' happens, the existing logic sees that focus is not in the (now showing) pop-up, decides that's a light dismiss signal, and hides the pop-up. From the developer's point of view, the pop-up never opened. With this new code, light dismiss is handled when the 'focus' event is fired, and if it isn't cancelled. [1] w3c/uievents#88 Bug: 1307772 Fixed: 1354293 Change-Id: I20373bcd8aeef24cddac5abd4548e9dc9428abf1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3848846 Reviewed-by: David Baron <[email protected]> Commit-Queue: Mason Freed <[email protected]> Auto-Submit: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1038350} -- wpt-commits: 1257a59c8df42427e11956d2265ba822465a938e wpt-pr: 35569
The problem is described in [1]. While the spec says 'focusin' should come before 'focus', because that makes sense, implementations actually do the reverse, including Chromium. That means that developer event listeners on 'focus' can show or hide a pop-up, and that gets completed before the 'focusin' handler gets called. Then, when 'focusin' happens, the existing logic sees that focus is not in the (now showing) pop-up, decides that's a light dismiss signal, and hides the pop-up. From the developer's point of view, the pop-up never opened. With this new code, light dismiss is handled when the 'focus' event is fired, and if it isn't cancelled. [1] w3c/uievents#88 Bug: 1307772 Fixed: 1354293 Change-Id: I20373bcd8aeef24cddac5abd4548e9dc9428abf1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3848846 Reviewed-by: David Baron <[email protected]> Commit-Queue: Mason Freed <[email protected]> Auto-Submit: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1038350} NOKEYCHECK=True GitOrigin-RevId: 57df05daeec7fe3dea09694854601b8b54e667af
#185 tracks moving all of this to the HTML Standard, for anyone wondering. |
What the spec defines is actually useful behavior, but unfortunately implementations do something totally different. (and that something else happens to be rather useless.) See for example jquery/jquery#3123
@adrianba @RByers @jacobrossi @rniwa would blink/webkit/edge be interested in to fix their implementations, or should we change the spec? (I assume the latter)
There is also the option to remove the events altogether.
The text was updated successfully, but these errors were encountered: