From 63cb3d99f55ddb280c66f46fbd970651351009c8 Mon Sep 17 00:00:00 2001 From: mmakarin Date: Thu, 1 Oct 2015 16:24:57 +0300 Subject: [PATCH 1/2] Fix for https://github.com/onefinestay/react-daterange-picker/issues/70 --- src/DateRangePicker.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DateRangePicker.jsx b/src/DateRangePicker.jsx index 2df54ebe..81054c24 100644 --- a/src/DateRangePicker.jsx +++ b/src/DateRangePicker.jsx @@ -481,7 +481,7 @@ const DateRangePicker = React.createClass({ value = null; } } else if (isMomentRange(value)) { - if (!monthRange.overlaps(value)) { + if (!monthRange.overlaps(value) && !monthRange.end.isSame(value.start) && !monthRange.start.isSame(value.end)) { value = null; } } From e63ff7f93eced301b2ebd27122c749212925446a Mon Sep 17 00:00:00 2001 From: Rob Masters Date: Wed, 11 Oct 2017 10:42:43 +0100 Subject: [PATCH 2/2] Fix for highlighted date ranges when on first/last day of week and month --- src/DateRangePicker.jsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/DateRangePicker.jsx b/src/DateRangePicker.jsx index 81054c24..69501a38 100644 --- a/src/DateRangePicker.jsx +++ b/src/DateRangePicker.jsx @@ -476,21 +476,25 @@ const DateRangePicker = React.createClass({ let monthEnd = monthDates.last().last(); let monthRange = moment.range(monthStart, monthEnd); + const isRangeVisible = range => ( + monthRange.overlaps(range) || + monthRange.end.isSame(range.start) || + monthRange.start.isSame(range.end) + ); + if (moment.isMoment(value)) { if (!monthRange.contains(value)) { value = null; } - } else if (isMomentRange(value)) { - if (!monthRange.overlaps(value) && !monthRange.end.isSame(value.start) && !monthRange.start.isSame(value.end)) { - value = null; - } + } else if (isMomentRange(value) && !isRangeVisible(value)) { + value = null; } if (!moment.isMoment(highlightedDate) || !monthRange.contains(highlightedDate)) { highlightedDate = null; } - if (!isMomentRange(highlightedRange) || !monthRange.overlaps(highlightedRange)) { + if (!isMomentRange(highlightedRange) || !isRangeVisible(highlightedRange)) { highlightedRange = null; }