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 3c963ecd2..532eac1b0 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'; @@ -16,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 { @@ -80,6 +89,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]; @@ -123,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)} - } + )} ); 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"