Skip to content

Commit

Permalink
fix(date-field): fix limited datepicker feature
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasAuger committed Feb 27, 2020
1 parent 35cfe58 commit f2b223d
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/DateField.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,31 @@ class DateField extends React.Component {
}

isBeforeMinDate(date) {
return exists(this.props.minDate) && date < new Date(this.props.minDate);
if (!exists(this.props.minDate)) {
return false;
}

const minDate = new Date(this.props.minDate);

return date < this.getDateToUTC(
minDate.getFullYear(),
minDate.getMonth(),
minDate.getDate()
);
}

isAfterMaxDate(date) {
return exists(this.props.maxDate) && date > new Date(this.props.maxDate);
if (!exists(this.props.maxDate)) {
return false;
}

const maxDate = new Date(this.props.maxDate);

return date > this.getDateToUTC(
maxDate.getFullYear(),
maxDate.getMonth(),
maxDate.getDate()
);
}

isDayDisabled(date) {
Expand Down

0 comments on commit f2b223d

Please sign in to comment.