From 6d8a952f89ec2245aa8d270c0243c1f816e80b5a Mon Sep 17 00:00:00 2001 From: Nitin Shetty Date: Thu, 10 Mar 2016 11:26:00 -0600 Subject: [PATCH] [Datepicker] Add a check to fetch current system date Added a check which helps pick the current system date when the date-picker dialog is opened. Resolves callemall/material-ui#3545 --- src/date-picker/date-picker.jsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/date-picker/date-picker.jsx b/src/date-picker/date-picker.jsx index d9446880817c21..f87674f29ac55d 100644 --- a/src/date-picker/date-picker.jsx +++ b/src/date-picker/date-picker.jsx @@ -212,9 +212,20 @@ const DatePicker = React.createClass({ * Open the date-picker dialog programmatically from a parent. */ openDialog() { - this.setState({ - dialogDate: this.getDate(), - }, this.refs.dialogWindow.show); + /** + * if the date is not selected then set it to new date + * (get the current system date while doing so) + * else set it to the currently selected date + */ + if (this.state.date !== undefined) { + this.setState({ + dialogDate: this.getDate(), + }, this.refs.dialogWindow.show); + } else { + this.setState({ + dialogDate: new Date(), + }, this.refs.dialogWindow.show); + } }, /**