-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Picker opening when leaving / coming back to browser window #160
Comments
It's a focus/blur thing, i've done this to fix it
I've done this for both date and time pickers.. but yeah it's annoying |
Thanks for the tip, I'll do that for now. |
Once again, @brunogaspar, thanks for the quick tip. The only shortcoming of this solution is that the users lose their tabindex flow – which can be especially annoying if the field falls within a long form. The only solution off the top of my head is to watch the page visibility api. When the user focuses onto the page and the date input was the last focused element, trigger a |
I noticed an issue, not sure if it is related to the snippet i posted, but if i press the enter key it opens the date/picker-picker, my workaround was to disable the enter key on forms that has date/time pickers, but i haven't done much testing to see what is the cause. |
@brunogaspar, the solution works for me - thank you. |
Same, annoying thing. |
@amsul should we be aiming to add our own event hooks with the page visibility API or is this something that can be added to the API? |
@darrenhaken, you’d have to add your own event hooks - there’s nothing within the API that compensates for it just yet.. |
@amsul why not include @brunogaspar 's solution to the project's code.
I consider this as a bug. 🐛 |
@lijunle because that’s not really great for accessibility. You lose keyboard focus from the The right way to do it is by checking the page visibility and closing it with focus if needed. I’ve marked this for release in v3.6. If someone wants to take a stab at it, please feel free to :) |
Hi, @amsul . Thanks for your reply, I do not get your meaning of
Could you please explain more? |
@lijunle yeah, in a comment above I wrote:
Here’s the page visibility API: https://developer.mozilla.org/en-US/docs/Web/Guide/User_experience/Using_the_Page_Visibility_API |
I don't think the datepicker should pop up once the input box is focus. Split the focus and date picker pop up to two stages is better:
With this approach, there is no need to use visibility API. How do you think about this? |
@lijunle that’s an interesting approach. Although, I feel that it should only be split into two steps if there’s a way to enter data without the picker being opened. That’s why the native date input on desktop splits it into a separate "dropdown" button, whereas on mobile it's a one tap action because it’s the only way to enter a value. But regardless, using the current API, you can already achieve the mechanics you’re proposing by initializing like this: $('#input').pickadate({
editable: true
}) ..and then binding a focus event that does something like this: $('#input').on('focus', function() {
// open the picker when enter/space is pressed
}) |
So any progress on this? It's been nearly 2 years for such an apparent bug |
I just did:
To prevent the re-opening after switching tabs |
@RobertLowe working nice : ) Thanks |
I added a check onOpen to see if the target class is already present. Does the job well enough for my situation: $input.pickadate({
onOpen: function () {
if ($input.hasClass('picker__input--target')) {
$input
.pickadate()
.pickadate('picker')
.close(true);
}
}
}); |
Works for me too. It appears to be a bug : should release the focus when the dialog is closing. |
Guys, I want to go to next field if I press TAB, but Datepicker is opening. I am already tried the blur method, but it's not working. Maybe because I am using date and time picker together?
|
@adrianmihalko I have same problem |
Hi, actually in my case
was not working. I had to blur the holder of the picker box with:
|
This is how you fix it properly... add this to your pickadate config when you set it and it will blur the particular instance that was closed, and not ALL instances (as the above code does):
|
@adrianmihalko Did you solve your problem? In my case even with the input disabled the tab opens the picker |
The "reopening calendar" has bugged me too but the solution I found today was very easy:
The only glitch is that the event 'open' is fired three times. I dont know why but there are not visual artifacts. |
@hidingmode After trying every solution in this thread, this is the combination that worked for me. I have to close both the |
@RobertLowe thanks a lot! |
This worked for me:
|
I tried them all. None worked. But putting this before the config options worked:
|
This is so hacky... but I found. putting a hidden "dummy" input before the pickadate one stopped the unwanted behaviour. |
I've tried every solution on this page. Nothing works. This always seems to happen when using external libraries. You save time by implementing an external library, then you find some bug. You search and find posts offering a million solutions that do not work going back years (five in this instance). It's probably best to build something like this from scratch that works exactly as you imagine. Honestly, how difficult can it be? |
Says the guy who joined github 15 minutes ago... You should adjust your attitude here's why:
How difficult can it be. Very, that's why software professionals have a job, nothing is perfect. On a side note, yes, you'll need to go through many resources to find a solution for a specific problem, and over time, you gain something called experience which helps you adapt and manage problems with greater ease. |
Sorry, I didn't mean any offense. I did just create a github account so I could leave a comment. I'll concede that my commentary was unwarranted, and that of course nothing is owed to me. This is the solution I found that worked for me:
Perhaps others can rewrite this without the use of a global variable. Right now, this is good enough for me. Hope this helps. Edit: updated code to work for a more generic situation. @RobertLowe - PS, you were pretty great in The Outsiders. Cheers! |
Hi, thanks for the update. Is there something that we can do / fix in pickadate to prevent this? |
It would be nice if the datepicker did not automatically reopen when a user returns to the browser tab. For example:
I was able to make a simple solve by creating a global variable that tracked whether the date picker had been closed and use it in the onOpen & onClose events. My fix is a kludge, but perhaps a similar but more elegant solution can be incorporated into pickadate. |
I think it is related to some focus. |
Adding |
So this is not new ;-) Would like someone to create a PR for this? |
First of all, Pickadate is just awesome (well built, great api, highly extensible, a pleasure to work with).
Thanks for it, I just discoverd it and I feel that it will become my only reference for date/time picker.
I did find a small issue that I think can be easily fixed:
Steps to reproduce:
Tested on Google Chrome Version 27.0.1453.110
I hope you have enough infos to fix, keep on the great work!
The text was updated successfully, but these errors were encountered: