onefinestay / react-daterange-picker

Other
563 stars 208 forks source link

Missing CSS on start date when setting the range value in default #63

Closed tennisonchan closed 6 years ago

tennisonchan commented 9 years ago

The css of the start date is missing when setting the range value as default state.

The value range is a moment-range object. screen shot 2015-08-24 at 8 50 46 pm

screen shot 2015-08-24 at 8 47 41 pm

puzzfuzz commented 9 years ago

+1 I'm running into this issue as well. Start date is not being highlighted on initial set using manually created moment.range, however it is when selecting a range from calendar. Only difference I see in the objects going in to the value attribute and those coming out of the onSelect callback are they moment objects have a _i attribute on them when created by the calendar.

puzzfuzz commented 9 years ago

Issue is with moment.range's contains calculation, which uses timestamps when comparing dates. The date's on the calendar days are all at midnight, so a start date at 00:00:00 will fail the contains check. I've submitted a PR that fixes this by setting the CalendarDate's time to 00:01:00, thus allowing a range starting at midnight that day to contain the day in question.

AlanFoster commented 8 years ago

@tennisonchan / @puzzfuzz Would we be happy closing this issue as the issue lies with moment.range ?

For visibility was your PR merged in @puzzfuzz ?

puzzfuzz commented 8 years ago

My PR was not merged in, but I don't think it's necessary anymore - I've got it working using a vanilla version of this control (I may have been using the moment.range object wrong, though it was a while ago now).

Close away. Thanks!

chrisdrackett commented 8 years ago

I'm running into this as well. @puzzfuzz: what did you do to fix it?

cp commented 8 years ago

@puzzfuzz I'm running into this same thing now. How did you manage to fix it?

tennisonchan commented 8 years ago

@cp @puzzfuzz I encountered that same issue from moment.range. My approach was to make sure time was set with the same timezone, in my case, I use UTC.

@puzzfuzz please feel free to close this once you solve this issue. Thanks!

cp commented 8 years ago

I think I solved this by making sure my moment objects were at the start of the day, before constructing the range. #moment.startOf('day')

AlanFoster commented 6 years ago

Closing this ticket off now, the solution is to ensure you are using the start of day/end of day functionality as mentioned above :+1: