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

Deleting selections from multi-select using backspace causes browser back in IE11 #3168

Closed
RochDs opened this issue Mar 17, 2015 · 22 comments
Closed

Comments

@RochDs
Copy link

RochDs commented Mar 17, 2015

Deleting the tag using backspace causes browser back. This occurs in IE 11 but not in Chrome 41.0.

Jsfiddle: http://jsfiddle.net/6XvqX/822/

@kevin-brown
Copy link
Member

I was able to reproduce the issue locally in IE, will do more testing later.

@RochDs
Copy link
Author

RochDs commented Mar 18, 2015

Thank you Kevin!

@miguellobato84
Copy link

Still having the problem in IE9 and rc2

@miguellobato84
Copy link

Solved modifying the following code:

this.$selection.on('keydown', '.select2-search--inline', function (evt) {
    evt.stopPropagation();
    self.trigger('keypress', evt);
    self._keyUpPrevented = evt.isDefaultPrevented();
    var key = evt.which;
    if (key === KEYS.BACKSPACE && self.$search.val() === '') {
        var $previousChoice = self.$searchContainer.prev('.select2-selection__choice');
        if ($previousChoice.length > 0) {
            var item = $previousChoice.data('data');
            self.searchRemoveChoice(item);
            self.$search.val("").blur().focus();
            evt.preventDefault();
        }
    }
});

@kevin-brown
Copy link
Member

This is fixed on master but is not yet in a release.

@RochDs
Copy link
Author

RochDs commented May 7, 2015

Hi Kevin, when will this fix be available in the release?

@kevin-brown
Copy link
Member

This should have been included in the 4.0.0 release that went out about two weeks ago. Can you confirm if you are still having issues with it?

@RochDs
Copy link
Author

RochDs commented May 11, 2015

Hi Kevin, I have not yet taken the latest release. I will get it, and revert incase of issues.

@nfriend
Copy link

nfriend commented May 20, 2015

I am experiencing this issue in IE 11 when using select2.js or select2.min.js, but not when using select2.full.js.

As a side note, the fix in select2.full.js disables the backspace key completely after the deletion of a single tag, which is certainly better than navigating backwards in history, but still not as satisfactory as the expected behavior of continued tag deletion.

@kevin-brown
Copy link
Member

I am experiencing this issue in IE 11 when using select2.js or select2.min.js, but not when using select2.full.js.

Do you want to create a pair of jsfiddles (one with the full, one with the regular build) and a step by step set of instructions for how you are testing?

I'm not sure what would be included in the full builds that would be affecting this.

@nfriend
Copy link

nfriend commented May 21, 2015

I can't seem to reproduce the difference between select2.js and select2.full.js in a jsfiddle - perhaps I was just using an out-of-date version of library before. I am still getting the backspace = back behavior using either version of the library in IE11, however:

Both jsfiddles use the latest version of library from the /dist directory on master. To reproduce (in IE11):

  • Select more than one option inside the Select2 control
  • Try to delete all of the selected options using backspace

@thomashertog
Copy link

any updates on this issue?
I'm still experiencing this issue.
My setup is Select2-4.0.0 (doesn't matter whether I use the full or the normal script file)
Using IE 11

@licicego
Copy link

licicego commented Jun 2, 2017

Using select2 with multiple tags in my project, the following code helped:

  $(".select2-selection__rendered").on('keydown', function (e) {
        if ($(".select2-search__field valid").prevObject.context.activeElement.value == "" && e.which === 8) {
            event.preventDefault();
        }
    });

@MtarantoOa
Copy link

Hi guys Im using select2 in an Angular 2 template. We use the backspace key to delete the tags of the input. We found this solution:
`

$.fn.select2.amd.require(['select2/selection/search'], function (Search) {
			var oldRemoveChoice = Search.prototype.searchRemoveChoice;

			Search.prototype.searchRemoveChoice = function () {
				oldRemoveChoice.apply(this, arguments);
				this.$search.val('');
			};
		});

`

That work great on Chrome. But on IE the second time I hit the backspace key the browser just go back.
I was looking for some solution like change the version of the library but it does not work for me.

Im using this version: "select2": "4.0.3"

Do you know any workaround or how to fix this?

@alexweissman
Copy link
Contributor

Have you tried pulling the master branch?

This is fixed on master but is not yet in a release.

@MtarantoOa
Copy link

@alexweissman Thanks for you answer.
Im using this library
https://github.com/NejcZdovc/ng2-select2

It uses select2 and I get the code of the library from npm. I think it get from master branch.
I manually download and replace the files and still not working.

Thanks!

@alexweissman
Copy link
Contributor

It looks like the wrapper pulls the last release (not master): https://github.com/NejcZdovc/ng2-select2/blob/master/package.json#L31

Also, have you confirmed that this is still an issue even without using the wrapper?

@qw789
Copy link

qw789 commented Sep 15, 2017

It is still not working in IE11.......

@alexweissman alexweissman added this to the 4.0.6 milestone Dec 8, 2017
@alexweissman alexweissman changed the title Deleting the tags using backspace causes browser back Deleting selections from multi-select using backspace causes browser back Dec 8, 2017
@alexweissman alexweissman changed the title Deleting selections from multi-select using backspace causes browser back Deleting selections from multi-select using backspace causes browser back in IE11 Dec 8, 2017
@alexweissman
Copy link
Contributor

It would seem that this is still a problem, even in 4.0.6-rc.1 with the fix from #4860.

@alexweissman
Copy link
Contributor

#3394 claims to resolve this problem.

@pedrofurtado
Copy link
Contributor

Discussion continues here -> #3394

@christopheroussy
Copy link

This is still broken with version 4.0.7 and IE11 on windows 10.

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

Successfully merging a pull request may close this issue.