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

IE 11 firing onBlur when scrolling the dropdown content #1004

Closed
ghost opened this issue Feb 11, 2016 · 18 comments
Closed

IE 11 firing onBlur when scrolling the dropdown content #1004

ghost opened this issue Feb 11, 2016 · 18 comments

Comments

@ghost
Copy link

ghost commented Feb 11, 2016

When testing our app in IE 11 we found that clicking on the scrollbar in the selectize dropdown content caused the dropdown to close. Other browsers did not have this behaviour.

I tracked the issue down to the blur event on the text input. IE fires the blur event when you click on the scrollbar, other browsers do not.

I found some code in onBlur which seemed like it was designed to detect this and prevent the selectize dropdown from closing:

 } else if (!self.ignoreBlur && document.activeElement === self.$dropdown_content[0]) {
    // necessary to prevent IE closing the dropdown when the scrollbar is clicked

However it wasn't working (for us at least) because document.activeElement was the <div class='selectize-dropdown single' ...> and self.$dropdown_content[0] was the <div class='selectize-dropdown-content'>, i.e. the child of the first div.

I was able to fix this by adding the .parentElement blow.

 } else if (!self.ignoreBlur && document.activeElement === self.$dropdown_content[0].parentElement) {
    // necessary to prevent IE closing the dropdown when the scrollbar is clicked

This issue is present in 0.12.0 and 0.12.1.

@bb1
Copy link

bb1 commented Jul 22, 2016

Could you make a pull request out of this? I have the same problem and your fix is working.
Affects IE11.

@Thorarin
Copy link

Your fix does not work for me.

When I try to scroll down in IE11, the onBlur function gets called twice. The first time matches the conditional of the original code, self.ignoreBlur is set to true.

The second event then closes the dropdown, because self.ignoreBlur is already true, no early exit from the function. What looks dodgy to me is that 2 lines higher, a check is done against self.ignoreFocus and not self.ignoreBlur. I have however not yet found a working solution.

Thorarin pushed a commit to Thorarin/selectize.js that referenced this issue Nov 14, 2016
@Thorarin
Copy link

I've made some changes that seem to fix the issue for me (see commit above). However, I only use limited functionality of the component. It's not tested extensively, so YMMV.

@lewishowles
Copy link

Just wanted to add that I spent quite a while chasing this bug down, including trying a lot of other things (removing all my JS and CSS to ensure there were no conflicts, and other fixes mentioned in closed bugs) but @d4nt's solution was the one that worked in the latest version of Selectize.

@KyorCode
Copy link

Unfortunately this is still an issue in IE10/IE11. Any hope on a fix?

@theodorapaja
Copy link

This fix was not working for me because document.activeElement was always returning as body. Instead of checking document.activeElement I'm now checking e.target against self.$control_input (not self.$dropdown_content) as follows:

} else if (!self.ignoreBlur && e && e.target === self.$control_input[0]) {
// necessary to prevent IE closing the dropdown when the scrollbar is clicked

(Note: I'm using v0.12.1 on IE11)
@KyorCode

@moussa-b
Copy link

I have this issue with IE 11 and the latest update version : 11.0.47 (KB4040685) which was released the 10.10.2017. I didn't have the issue with previous IE 11's update version 11.0.45 and 11.0.20.
For me solution given by @d4nt doesn't work but solution given by @theodorapaja works fine.

@worthy7
Copy link

worthy7 commented Oct 18, 2017

Hi guys, I come from typeahead.
@theodorapaja what is $control_input? Is it an <input> or something in the dropdown? I'm trying to replicate your fix over in typeahead.js

For me, the event is always the same. If clicking the background, or clicking the scrollbar. I checked most of the properties too, and they are the same. So the event is an unreliable thing to use now. Thanks M$!

I posted my current very dirty solution over yonder:
corejavascript/typeahead.js#166

@neilmonroe
Copy link

Now this is interesting. I did not test in IE 11, but the only browser I tested that didn't hide the drop down when clicking the scrollbar was Edge. Windows Chrome and Firefox, and Mac Safari, Chrome and Firefox all hide the drop down after clicking on the scrollbar with the mouse.

iOS and Android browsers seem to not be affected because the touch event is most-likely being triggered on top of the drop down still.

I will post a fix if I find one that works across the board.

@worthy7
Copy link

worthy7 commented Oct 25, 2017

That's quite odd, I can only imagine this is due to some deeper settings specific to selectize.js (which I'm not involved in), and whatever it is, is taken care of over in the typeahead.js repo. Perhaps you could take a look over there to get some idea's how to fix this repo?

@acromarco
Copy link

This bug can be probably solved by adding tabindex="-1" to the dom element which has the scrollbars.

@indrapolak
Copy link

indrapolak commented Oct 27, 2017

I used @theodorapaja 's suggestion and that worked for me for IE 11.0.47; however it also broke something: now clicking on an option does not close the dropdown anymore.

Therefore this solution is far from perfect. The blur raised by the close of the option (after clicking an option) must be treaten different from the blur raised because you clicked on the scrollbar. Why does clicking the scrollbar trigger a blur event?

@worthy7
Copy link

worthy7 commented Oct 30, 2017

Doesn't seem to be doing the trick, tabindex="-1" on the <option> tag right?

@fredrik-lundin
Copy link

Me and my colleague ended up with the following solution. This prevents the scrollbar from closing the dropdown menu in IE11 while still closing the dropdown when an item is selected. Also tested in chrome and firefox.

onBlur: function(e, dest) {
    var self = this;

    if (e && e.target === self.$control_input[0]) {
        return;
    }
    ......
}

@cphill02
Copy link

This seems pretty critical will it get fixed soon?
@fredrik-lundin 's fix work around worked for me.

@worthy7
Copy link

worthy7 commented Dec 13, 2017

@cphill02 The tabindex="-1" stuff does work, I think it just has to be on the select element. (I did get it working in the end, and other JS solutions ended up lagging IE)

@yesmeck
Copy link

yesmeck commented Jan 22, 2018

FYI, I opened a issue to Microsoft https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/15558714/

@risadams
Copy link
Contributor

closing stale issues older than one year.
If this issue was closed in error please message the maintainers.
All issues must include a proper title, description, and examples.

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

No branches or pull requests