Event: Simulate focus/blur in IE via focusin/focusout#5223
Merged
Conversation
b6be579 to
8cc5ff1
Compare
Member
Author
|
The |
This was referenced Mar 13, 2023
ac380e3 to
3a1bd2d
Compare
Member
Author
|
@timmywil I added a few commits on top of the original PR so I'm re-requesting a review from you. |
7d67295 to
79daba0
Compare
mgol
commented
Mar 15, 2023
| this | ||
| ) | ||
| } ); | ||
| dataPriv.set( this, type, jQuery.event.trigger( |
Member
Author
There was a problem hiding this comment.
@gibson042 One thing to note - while #4350 which added this wrapping was mainly aimed at IE with its async focus handlers, there has been a report about this also affecting Chrome somehow:
#4350 (comment)
I'm not sure if we can do anything about it due to the lack of data, though.
79daba0 to
02906a8
Compare
02906a8 to
7022908
Compare
Member
Author
|
It looks like this also fixes #4950; I added a test for this in a separate commit & verified it fails on |
Member
Author
|
This also seems to fix one heavily upvoted select2 issue: select2/select2#5993. |
In IE (all versions), `focus` & `blur` handlers are fired asynchronously but `focusin` & `focusout` are run synchronously. In other browsers, all those handlers are fired synchronously. Simulate `focus` via `focusin` & `blur` via `focusout` in IE to avoid these issues. Fixes jquerygh-4856 Fixes jquerygh-4859 Fixes jquerygh-4950
Tests added: * sequences triggering focus and/or blur (authored by Richard Gibson) * focus does not bubble * some test stability fixes Co-authored-by: Richard Gibson <[email protected]>
With IE now using `focusin` to simulate `focus` and `focusout` to simulate `blur`, we don't have to deal with async events in `leverageNative`.
Now that jQuery focus/blur events in IE are not async, we can simplify some tests.
Focusing an input with `display: none` no longer prevents it from being focused when it gets shown later.
7022908 to
f5b7dc0
Compare
2 tasks
timmywil
approved these changes
Mar 27, 2023
mgol
added a commit
that referenced
this pull request
Mar 27, 2023
In IE (all versions), `focus` & `blur` handlers are fired asynchronously but `focusin` & `focusout` are run synchronously. In other browsers, all those handlers are fired synchronously. Asynchronous behavior of these handlers in IE caused issues for IE (gh-4856, gh-4859). We now simulate `focus` via `focusin` & `blur` via `focusout` in IE to avoid these issues. This also let us simplify some tests. This commit also simplifies `leverageNative` - with IE now using `focusin` to simulate `focus` and `focusout` to simulate `blur`, we don't have to deal with async events in `leverageNative`. This also fixes broken `focus` triggers after first triggering it on a hidden element - previously, `leverageNative` assumed that the native `focus` handler not firing after calling the native `focus` method meant it would be handled later, asynchronously, which was not the case (gh-4950). To preserve relative `focusin`/`focus` & `focusout`/`blur` event order guaranteed on the 3.x branch, attach a single handler for both events in IE. A side effect of this is that to reduce size the `event/focusin` module no longer exists and it's impossible to disable the `focusin` patch in modern browsers via the jQuery custom build system. Fixes gh-4856 Fixes gh-4859 Fixes gh-4950 Ref gh-5223 Closes gh-5224 Co-authored-by: Richard Gibson <[email protected]>
3 tasks
mgol
added a commit
to mgol/jquery
that referenced
this pull request
Mar 30, 2023
Previously, when `leverageNative` handled async events, there was a case where an empty placeholder object was set as a result. Covering both such an object and `false` required a `length` check. However, this is not necessary since jquerygh-5223 and the check was already simplified in other places; this one was missed. Ref jquerygh-5223
1 task
mgol
added a commit
that referenced
this pull request
Apr 3, 2023
Previously, when `leverageNative` handled async events, there was a case where an empty placeholder object was set as a result. Covering both such an object and `false` required a `length` check. However, this is not necessary since gh-5223 and the check was already simplified in other places; this one was missed. Closes gh-5236 Ref gh-5223
mgol
added a commit
that referenced
this pull request
Apr 3, 2023
Previously, when `leverageNative` handled async events, there was a case where an empty placeholder object was set as a result. Covering both such an object and `false` required a `length` check. However, this is not necessary since gh-5223 and the check was already simplified in other places; this one was missed. Closes gh-5236 Ref gh-5223 (cherry picked from commit dfe212d)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In IE (all versions),
focus&blurhandlers are fired asynchronouslybut
focusin&focusoutare run synchronously. In other browsers, allthose handlers are fired synchronously.
Simulate
focusviafocusin&blurviafocusoutin IE toavoid these issues.
Fixes gh-4856
Fixes gh-4859
Fixes gh-4950
+30 bytes
3.x-stableversion of this PR: #5224Checklist