Skip to content

Commit

Permalink
[#824] [luxon] Fix crashing on opening datetime picker in error state (
Browse files Browse the repository at this point in the history
…mui#829)

* [#824] Fix crashing if openning datepicker with error

* Make default datetimepicker example show today
  • Loading branch information
dmtrKovalenko authored Jan 2, 2019
1 parent 72e5c5b commit 9a5c6fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DateTimePicker } from 'material-ui-pickers';

export default class BasicDateTimePicker extends PureComponent {
state = {
selectedDate: new Date('2018-01-01T00:00:00.000Z'),
selectedDate: new Date(),
};

handleDateChange = date => {
Expand Down
9 changes: 5 additions & 4 deletions lib/src/_helpers/date-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,18 @@ export const findClosestEnabledDate = ({
maxDate = today;
}

let forward = utils.date(date);
let backward = utils.date(date);
let forward = date;
let backward = date;
if (utils.isBefore(date, minDate)) {
forward = minDate;
forward = utils.date(minDate);
backward = null;
}

if (utils.isAfter(date, maxDate)) {
if (backward) {
backward = maxDate;
backward = utils.date(maxDate);
}

forward = null;
}

Expand Down

0 comments on commit 9a5c6fc

Please sign in to comment.