VitaliiBlagodir / cordova-plugin-datepicker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Datepicker sometimes showing multiple "Today" entries

jondspa opened this issue · comments

Thanks for the great plugin!

I've been using it for years on iOS and Android. Lately I've seen a little trouble on iOS (not sure about Android). Every once in a while, after opening the datepicker, as I scroll near the current date, I see "Today" appearing on different days, usually near the current date. I do not see the multiple today's at the same time - sometimes it's correct on the current date, sometimes it's a day or two in the past. Any ideas?

I'm calling the plugin with these options:

 options = {
    date: myDate,
    mode: 'datetime',
    minuteInterval: 5,
    x: 400,
    y: 600
 };

myDate is either the current date or a date in the past.

I've checked multiple times during the day and don't find any hints to the problem.

Running
datepicker 0.9.3
cordova 9.0.0
cordova ios 4.2.1

Testing on an iOS device running 13.6.1.

Thanks!

  • Jon

Here's more information and a possible solution. I found this discussion:
https://stackoverflow.com/questions/48392577/refresh-internal-state-of-ios-uidatepicker-after-midnight

Note that the problem is not with the plugin but a problem inside Apple's UIDatePicker. To hopefully fix this I've commented out a few lines in the iOS version of DataPicker.m - below lines 1,3,4,5 commented out. This hopefully will force the plugin to regenerate the data picker every time. (showForPad is not used!)

Hope this helps someone!

  • Jon

(top of showForPhone)
//if(!self.datePickerContainer){
[[NSBundle mainBundle] loadNibNamed:@"DatePicker" owner:self options:nil];
//} else {
// self.datePickerContainer.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.4];
//}