-
Notifications
You must be signed in to change notification settings - Fork 20.5k
Event: Simulate focus/blur in IE via focusin/focusout (3.x version) #5224
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
Merged
Conversation
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
3 tasks
Member
Author
|
The |
49d2e2d to
c052f78
Compare
This was referenced Mar 14, 2023
d4e0cf8 to
9952fdc
Compare
Member
Author
|
It looks like this also fixes #4950; I added a test for this in a separate commit & verified it fails on |
dmethvin
approved these changes
Mar 17, 2023
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 <richard.gibson@gmail.com>
With IE now using `focusin` to simulate `focus` and `focusout` to simulate `blur`, we don't have to deal with async events in leverageNative.
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.
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.
9952fdc to
fd2653b
Compare
timmywil
approved these changes
Mar 27, 2023
This was referenced Mar 27, 2023
mgol
added a commit
to mgol/jquery
that referenced
this pull request
Apr 3, 2023
There was a comment claiming that there are two implementations of `safeActiveElement`. However, the one in `event.js` got removed in jquerygh-5224, even before the comment was added. This commit removes this obsolete comment. Ref jquerygh-5224
1 task
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.
Also, simplify
leverageNative- With IE now usingfocusinto simulatefocusandfocusoutto simulateblur, we don't have to deal withasync events in
leverageNative.Fixes gh-4856
Fixes gh-4859
Fixes gh-4950
+58 bytes
All tests are passing in IE 9-11, I verified manually.
main(4.x) version of this PR: #5223Checklist