Skip to content
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

Closed
wants to merge 12 commits into from

Conversation

ToreOlavKristiansen
Copy link
Contributor

This pull request includes a

  • Bug fix
  • New feature
  • Translation

The following changes were made

I changed allowClear.js to:

  • Fix IE browser back issue when clearing selections using backspace key.
  • Fix issue with not being able to start typing for both IE and Chrome after clearing using backspace or delete key.

If this is related to an existing ticket, include a link to it as well.
#3168

@alexweissman
Copy link
Contributor

@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) {
Copy link

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);
}

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

@caohanh1502
Copy link

caohanh1502 commented Aug 14, 2018

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.
I also tested on the newest dev version 4.0.6-rc.1 with Chrome 68 and IE 11, and the same things happen.

Codepen: https://codepen.io/caohanh1502/pen/MBRQWR
Debug view for IE 11: https://s.codepen.io/caohanh1502/debug/MBRQWR/

Click on the select2 to open the dropdown selection, then click on the input of datetimepicker. Result:

  • Chrome: The datetimepicker is shown but it hides immediately. The focus is set to the select2, and I cannot type anything into the input.
  • IE 11: The datetimepicker does not shown (I did not see the div appear in the IE's DOM explorer). The focus is set to the select2, but I can type into the input.
  • (Same with the normal input).

Note: Datetimepicker is just a thing to clearly show that the input has focus but then it loses focus because of the select2.

albingi and others added 2 commits September 4, 2018 22:13
The test return always 's' in translations : inputTooLong, inputTooShort, maximumSelected
@pedrofurtado
Copy link
Contributor

#3394

@pedrofurtado pedrofurtado changed the base branch from master to develop September 15, 2018 04:22
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.
@kevin-brown
Copy link
Member

Unfortunately this pull request contains files in the dist folder, and as a result there is a merge conflict. Because this pull request is also pretty old (our fault), we are closing this off.

If you are still interested in making this contribution, feel free to remove the dist changes from this pull request and leave a comment asking for this to be re-reviewed. Or make a new pull request from the same branch, and we'll try to get around to reviewing it this time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants