Clicking on another input when selectize has focus does not fire 'focus' event on input (Internet Explorer)
Consider a situation where you have a selectize control and another input ("Input A"). The second input has a handler registered to the 'focus' event. In Internet Explorer, if the user clicks into the selectize control and then clicks on "Input A" the focus event is not fired.
The problem seems to be something in selectize's onBlur function, but I haven't been able to pin-point it. Also, the issue is not observed when using the "tab" key to change focus between elements.
I've observed this in IE 11 and simulated versions of IE10 and IE9.
You can see a plnkr of the issue here: http://embed.plnkr.co/E0jodB0liZKCQi7iu2P6/preview -- you'll need to have the console open
I have also observed this issue in IE10, IE11. Interestingly, if "Input A" has the HTML5 Placeholder attribute specified, typing (without focus) will append to the placeholder text, and not the change the input value.
This is by no means a solution, but I was able to get around this "ghost-focus" behaviour by manually setting the focus with a jQuery click event handler for Input A:
$('#InputA').click(function () {
$(this).focus();
});
We have this bug too, even with the latest version ... I've implemented @CountHesley fix and it work well, put I would prefer the library to cleanup correctly!
I believe this code to be the culprit.
$document.on('mousedown' + eventNS, function(e) {
if (self.isFocused) {
// prevent events on the dropdown scrollbar from causing the control to blur
if (e.target === self.$dropdown[0] || e.target.parentNode === self.$dropdown[0]) {
return false;
}
// blur on click outside
if (!self.$control.has(e.target).length && e.target !== self.$control[0]) {
self.blur();
}
}
});
I suggest to focus on the events target after the blur by calling e.target.focus(). I've tried it locally and it seems to work.
Can someone maybe challenge me about whether it would be a good or bad idea?
Running into the same issue. Our application is data centric with lots of field masks and selectize lists so the issue comes up often. @perrej fix seems to work. Would love to get it put into a future release
I created a pull request for this about two months ago.... #599