From c3479e43906b7fd9590a0165956112aa131576bb Mon Sep 17 00:00:00 2001 From: Phillip Chaffee Date: Tue, 2 Aug 2022 14:10:59 -0700 Subject: [PATCH 1/3] End date of a selected range has a time of 23:59:59. --- src/components/DateRange/index.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/DateRange/index.js b/src/components/DateRange/index.js index 3c963ecd2..dfa33b542 100644 --- a/src/components/DateRange/index.js +++ b/src/components/DateRange/index.js @@ -3,7 +3,15 @@ import PropTypes from 'prop-types'; import Calendar from '../Calendar'; import { rangeShape } from '../DayCell'; import { findNextRangeIndex, generateStyles } from '../../utils'; -import { isBefore, differenceInCalendarDays, addDays, min, isWithinInterval, max } from 'date-fns'; +import { + isBefore, + differenceInCalendarDays, + addDays, + min, + isWithinInterval, + max, + endOfDay, +} from 'date-fns'; import classnames from 'classnames'; import coreStyles from '../../styles'; @@ -80,6 +88,11 @@ class DateRange extends Component { } } + if (endDate) { + // The returned range should include the end date + endDate = endOfDay(endDate); + } + if (!nextFocusRange) { const nextFocusRangeIndex = findNextRangeIndex(this.props.ranges, focusedRange[0]); nextFocusRange = [nextFocusRangeIndex, 0]; From 370d7d4a79bc7b28bdea1b2c745db9bad848518f Mon Sep 17 00:00:00 2001 From: Phillip Chaffee Date: Tue, 2 Aug 2022 14:11:19 -0700 Subject: [PATCH 2/3] Lint fixes. --- src/components/Calendar/index.js | 2 +- src/components/DateRange/index.js | 2 ++ src/components/DayCell/index.js | 5 ++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/Calendar/index.js b/src/components/Calendar/index.js index 73b9faa48..79e64c2cf 100644 --- a/src/components/Calendar/index.js +++ b/src/components/Calendar/index.js @@ -493,7 +493,7 @@ class Calendar extends PureComponent { isVertical ? this.styles.monthsVertical : this.styles.monthsHorizontal )}> {new Array(this.props.months).fill(null).map((_, i) => { - let monthStep = addMonths(this.state.focusedDate, i);; + let monthStep = addMonths(this.state.focusedDate, i); if (this.props.calendarFocus === 'backwards') { monthStep = subMonths(this.state.focusedDate, this.props.months - 1 - i); } diff --git a/src/components/DateRange/index.js b/src/components/DateRange/index.js index dfa33b542..532eac1b0 100644 --- a/src/components/DateRange/index.js +++ b/src/components/DateRange/index.js @@ -24,6 +24,7 @@ class DateRange extends Component { }; this.styles = generateStyles([coreStyles, props.classNames]); } + calcNewSelection = (value, isSingleValue = true) => { const focusedRange = this.props.focusedRange || this.state.focusedRange; const { @@ -136,6 +137,7 @@ class DateRange extends Component { const color = ranges[focusedRange[0]]?.color || rangeColors[focusedRange[0]] || color; this.setState({ preview: { ...val.range, color } }); }; + render() { return ( - { - dayContentRenderer?.(this.props.day) || + {dayContentRenderer?.(this.props.day) || ( {format(this.props.day, this.props.dayDisplayFormat)} - } + )} ); From b4a0e034b3c932918f7c0cdcb210e342b195fbe0 Mon Sep 17 00:00:00 2001 From: Phillip Chaffee Date: Tue, 2 Aug 2022 14:11:37 -0700 Subject: [PATCH 3/3] Update caniuse browsers. --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index bef1242b4..e72d27b09 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2408,9 +2408,9 @@ camelcase@^5.0.0, camelcase@^5.3.1: integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30000989, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001219: - version "1.0.30001230" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001230.tgz#8135c57459854b2240b57a4a6786044bdc5a9f71" - integrity sha512-5yBd5nWCBS+jWKTcHOzXwo5xzcj4ePE/yjtkZyUV1BTUmrBaA9MRGC+e7mxnqXSA90CmCA8L3eKLaSUkt099IQ== + version "1.0.30001373" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001373.tgz" + integrity sha512-pJYArGHrPp3TUqQzFYRmP/lwJlj8RCbVe3Gd3eJQkAV8SAC6b19XS9BjMvRdvaS8RMkaTN8ZhoHP6S1y8zzwEQ== capture-exit@^2.0.0: version "2.0.0"