Skip to content

Commit

Permalink
fix checking same year for #289 edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
leebyp committed Jan 27, 2017
1 parent 142214d commit e9005d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/datetime/examples/dateRangePickerExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class DateRangePickerExample extends BaseExample<IDateRangePickerExampleS
className={Classes.ELEVATION_1}
onChange={this.handleDateChange}
initialMonth={new Date(2017, 11)}
minDate={new Date(2016, 11)}
/>
<div>
<Moment date={start} />
Expand Down
6 changes: 4 additions & 2 deletions packages/datetime/src/dateRangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ export class DateRangePicker
// allowable range, the react-day-picker library will show
// the max month on the left and the *min* month on the right.
// subtracting one avoids that weird, wraparound state (#289).
const initialMonthEqualsMinMonth = initialMonth.getMonth() === props.minDate.getMonth();
const initalMonthEqualsMaxMonth = initialMonth.getMonth() === props.maxDate.getMonth();
const initialMonthEqualsMinMonth = initialMonth.getMonth() === props.minDate.getMonth()
&& initialMonth.getFullYear() === props.minDate.getFullYear();
const initalMonthEqualsMaxMonth = initialMonth.getMonth() === props.maxDate.getMonth()
&& initialMonth.getFullYear() === props.maxDate.getFullYear();
if (!initialMonthEqualsMinMonth && initalMonthEqualsMaxMonth) {
initialMonth.setMonth(initialMonth.getMonth() - 1);
}
Expand Down

0 comments on commit e9005d2

Please sign in to comment.