MakingSense / moment-datepicker

[ABANDONED REPOSITORY] The best bootstrap datepicker!
Apache License 2.0
92 stars 64 forks source link

Calendar Picker is Not working on IE8 #30

Open umzi opened 11 years ago

umzi commented 11 years ago

First, your work is great. Secondly I am having a very major issue with IE8. If I click the textbox, it opens the calendar but upon selection, calendar doesn't update the textbox. If I click the calendar icon then the input field get's updated. Secondly if I type the date in input field , its clears up. Can you please assist me how can I fix it?

Thank you so much for your time and help :) Cheers.

eddielee6 commented 10 years ago

Yeah, I'm having this issue as well. Has any work been put in to solve this? If not I'm going to have a look myself.

eddielee6 commented 10 years ago

The issue appears to be line 210 where 'newValue' is null. In other browsers this is set to the time selected. Can't see why this is the case though.

eddielee6 commented 10 years ago

It appears 'newValue' always takes the value of the date picker when the control was initialised. If there was no value it is always null, if there was a value when it was initialised 'newValue' is always equal to that value. So its impossible to change the value. I'm having difficulty locating where "this.moment" on line 210 is set.

eddielee6 commented 10 years ago

Ah, the 'set' method isn't fired in IE8 when clicking an event.

eddielee6 commented 10 years ago

If you comment out the whole of the 'hide' method on line 160 it works fine (with the exception of the datepicker not hiding). It looks like there's some code above this in the _hide method to fix this (or a similar issue) however it is not having much effect.

eddielee6 commented 10 years ago

Right, I've found two fixes to this. This issue is that IE8 fires blur events before click events.

Fix 1

You can wrap the blur event on line 46 in a low setTimeout such as 8 milliseconds. This fixes the issue because it allows the click handler to fire before the blur handler.

Fix 2

You can delete the existing mousedown handler that stops propagation and then replace the click handler with mousedown. This fixes the issue because mousedown fires before blur in IE8.

Not sure which of these is the best solution.

eddielee6 commented 10 years ago

Pull request for "Fix 2" has been submitted - seems to be the best option.

eddielee6 commented 10 years ago

I have closed the pull request for "Fix 2" as it does not fix all the issues - while it fixed the issue with manually selecting a date with the mouse, it still did not enable typing into the input box.

After further testing of "Fix 2" it does fix all cases, so you can select a date with the mouse and type with the keyboard. However it stops the control from hiding correctly in some cases.

andresmoschini commented 10 years ago

Thanks for your help Eddie, I will try to review it at the weekend.

On Tue, Jun 24, 2014 at 8:25 AM, Eddie Lee notifications@github.com wrote:

I have closed the pull request for "Fix 2" as it does not fix all the issues - while it fixed the issue with manually selecting a date with the mouse, it still did not enable typing into the input box.

After further testing of "Fix 2" it does fix all cases, so you can select a date with the mouse and type with the keyboard. However it stops the control from hiding correctly in some cases.

— Reply to this email directly or view it on GitHub https://github.com/MakingSense/moment-datepicker/issues/30#issuecomment-46959523 .

eddielee6 commented 10 years ago

Cheers - I've tried a fair few fixes now and can't seem to fix the issues without breaking the blur event.

eddielee6 commented 10 years ago

Any ideas on the best way to get this working in IE8?