Skip to content
This repository was archived by the owner on Apr 18, 2026. It is now read-only.
This repository was archived by the owner on Apr 18, 2026. It is now read-only.

Clicking on another input when selectize has focus does not fire 'focus' event on input (Internet Explorer) #406

Closed

Description

@benmj

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

Activity

  1. changed the title [-]Clicking on another input while when selectize has focus does not fire 'focus' event on new element (Internet Explorer)[/-] [+]Clicking on another input when selectize has focus does not fire 'focus' event on new element (Internet Explorer)[/+] on May 12, 2014
  2. changed the title [-]Clicking on another input when selectize has focus does not fire 'focus' event on new element (Internet Explorer)[/-] [+]Clicking on another input when selectize has focus does not fire 'focus' event on input (Internet Explorer)[/+] on May 12, 2014
  3. CountHesley commented on Jul 10, 2014

    @CountHesley

    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();
    });
  4. cvillemure commented on Aug 21, 2014

    @cvillemure

    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!

  5. perrej commented on Oct 15, 2014

    @perrej

    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?

  6. bubb-rubb commented on Dec 10, 2014

    @bubb-rubb
    Contributor

    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

  7. perrej commented on Dec 12, 2014

    @perrej

    I created a pull request for this about two months ago.... #599

  8. added a commit that references this issue on Jan 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions