nazar-pc / PickMeUp

Really simple, powerful, customizable and lightweight standalone datepicker
BSD Zero Clause License
615 stars 191 forks source link

Bug with date field blur in Chrome #159

Closed kykint closed 7 years ago

kykint commented 7 years ago

In Firefox/Edge if you click in date field and then try clicking inside datepicker, focus will stay in date field. But in Chrome clicking in calendar removes focus from field. And it is producing blur event. So it is impossible to catch a real blur event (changing focus or clicking outside)

nazar-pc commented 7 years ago

What exactly problem does this cause?

kykint commented 7 years ago
  1. If you will open datepicker and start clicking inside, then you will want to enter date from keyboard you need to click on field again in Chrome.
  2. And in my solution - I'm using datepicker inside popup, which is closing and destroying by escape button. And by default if I click in field, there will be datepicker. After clicking escape - popup is closing, but datepicker still showed. I have fixed it by blur event, but received this bug only in Chrome
nazar-pc commented 7 years ago

I thought it should be possible to fix it with user-select: none on PickMeUp, but turns out it is not that easy.

  1. If you've started clicking already, I don't think it is such a big deal to click one more time. You can, however, restore focus on input field on click manually if you really want to, pretty straightforward to implement
  2. You should better listen on global key press events rather than on input field, this way you will not miss anything
kykint commented 7 years ago

user-select doesn't make any changes.

  1. I agree with you, but it is not consistent between different browsers (Chrome and all non-Chrome)
  2. It's difficult for me, because there are a lot of cases, when field can disappear.... Ok I'll find another solution for Chrome (don't like to make different solutions for different browsers, I third, that it stayed in 2000s).
nazar-pc commented 7 years ago
  1. I agree with you too, but this is caused by browsers, not this library, it doesn't work the way you've described by itself and thus shouldn't patch native behavior in this case
  2. Actually it is not. Just listen to show/hide events https://github.com/nazar-pc/PickMeUp#events-callbacks and add/remove global event listener for escape key, simple enough to implement, single solution to all modern browsers
kykint commented 7 years ago

I have solved problem for me, but I will not close this issue. We will not forget this problem - maybe someone else face it again. Thank you for this plugin!

nazar-pc commented 7 years ago

I'll close this for now, if someone have any other comments it is still possible to add them or event reopen issue again.