pickadate.js icon indicating copy to clipboard operation
pickadate.js copied to clipboard

Bug when changing the browser tab

Open blackgrow opened this issue 7 years ago • 8 comments

Hey guys! When i open the calendar then close and when you switch to another tab of the browser and return to the one where the calendar was opened, does it open itself again? why is this happening? Can this be how to muffle it?

blackgrow avatar Aug 10 '17 18:08 blackgrow

I noticed the same problem with all browsers. Is there a way to solve this issue?

aletiger avatar Aug 21 '17 13:08 aletiger

I investigated the problem. I think that is related to the fact that the input field has the focus and the calendar is always opened on the focus event. The date picker has the focus, so when you are back from another tab, the calendar will show up again.

I'm not able to get the focus lost when I close the calendar the first time. Any idea?

aletiger avatar Aug 24 '17 16:08 aletiger

@blackgrow If you are interested this should be a working solution.

<script> $('.datepicker').pickadate(); var $input = $('.datepicker').pickadate(); var picker = $input.pickadate('picker'); picker.on({ close: function() { console.log('Closed now'); $(document.activeElement).blur(); }, }) </script>

You need to blur() the focus when the calendar is closed. Best regards.

aletiger avatar Aug 25 '17 09:08 aletiger

CSS Workaround

.picker__holder{
	pointer-events: none;
}
.picker__frame	.picker__wrap{
	pointer-events: auto;
}

topest1 avatar Sep 05 '17 05:09 topest1

I think this bug was already reported on #160

The work around n that worked for me was adding the following to the initialization options:

   onClose: function(){
        $(document.activeElement).blur();
    }

00dav00 avatar Jan 10 '18 14:01 00dav00

Just note that blurring the active element upon closing the calendar would be bad for anyone using keyboard navigation, or who similarly relies on focus, and hurts accessibility.

Rykus0 avatar Feb 01 '18 02:02 Rykus0

CSS workaround fixes this. Is there any reason that this should not be added to the project?

JS solutions feel dirty, if a pure CSS solution also does the trick. Also, using blur does fix the problem but adds another one.

CptMeatball avatar Jun 08 '18 07:06 CptMeatball

CSS workaround does not work for me in v3.6.0

xtianus avatar Oct 07 '21 09:10 xtianus