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
Fixes IE browser back issue when clearing selections using backspace key #5161
Conversation
It also fixes issue with not being able to start typing for both IE and Chrome after clearning using backspace or delete key.
@cordmata @dmarginian can you please take a look at this PR, and see if it solves your other issues with IE? |
@@ -2019,7 +2027,13 @@ S2.define('select2/selection/search',[ | |||
|
|||
this.resizeSearch(); | |||
if (searchHadFocus) { | |||
this.$search.focus(); | |||
var isTagInput = this.$element.find('[data-select2-tag]').length; | |||
if (isTagInput) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make this work in IE11 with multiple tag support, I had to combine this code with the code presented in a comment on #4398:
if (isTagInput) {
// fix IE11 bug where tag input lost focus
window.setTimeout(function() {
self.$element.focus();
}, 0);
} else {
window.setTimeout(function() {
self.$search.focus();
}, 0);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one worked for me
I have a problem here. When I apply this fix, the browser would focus on the select2 again if I click on an input while the dropdown selection is still opened. It does not happen in v4.0.3. Codepen: https://codepen.io/caohanh1502/pen/MBRQWR Click on the select2 to open the dropdown selection, then click on the input of datetimepicker. Result:
Note: Datetimepicker is just a thing to clearly show that the input has focus but then it loses focus because of the select2. |
The test return always 's' in translations : inputTooLong, inputTooShort, maximumSelected
This reverts commit 5968dcc.
Fixed issue with x not clearing selection. It also avoids opening dropdown when clearing. By clicking the x, the user has opted to clear a value, not to also change the value or add another value. So it should not open.
… from the hidden select. Also added comment to make sure the toggle is not uncommented or reintroduced.
Unfortunately this pull request contains files in the If you are still interested in making this contribution, feel free to remove the |
This pull request includes a
The following changes were made
I changed allowClear.js to:
If this is related to an existing ticket, include a link to it as well.
#3168