Twipped / Kalendae

A javascript date picker that just works.
MIT License
1.99k stars 285 forks source link

IE8 blur handling doesn't always play nice #42

Closed jeroenp closed 8 years ago

jeroenp commented 12 years ago

Hi,

I get a

"htmlfile: Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus."

on $input.focus() in the onblur handler for IE8;

https://github.com/ChiperSoft/Kalendae/blob/master/src/input.js#L53

That's because I have another blur handler on the same input that causes display:none on the input and its surrounding HTML. Apparently my blur handler has been called before Kalendae, and IE8 doesn't like calling focus() on a hidden input element. And it shouldn't, because the blur is rightly called on the input and I'm done with the calendar editing at this point.

As far as I can tell, I have no way to manipulate the noclose variable. I would think that the hide() should set this variable as well. I don't even understand why noclose was set to true anyhow.

The $input is not a jquery object, by the way. It's the native HTMLDOMElement. I'm not sure if that's what you were expecting, given the variable name prefix...

kind regards, Jeroen

jeroenp commented 12 years ago

I've added a try/catch in my copy of kalendae, because I can't imagine ever being interested in failures on focus() requests:

    util.addEvent($input, 'blur', function () {
        if (noclose) {
            noclose = false;
            try {
                $input.focus();
            } catch (x) {
                ;
            }
        }
        else self.hide();
    });