Skip to content

Commit

Permalink
Merge pull request #3656 from tintin1343/datepicker-time-issue
Browse files Browse the repository at this point in the history
[Datepicker] Add a check to fetch current system date
  • Loading branch information
oliviertassinari committed Mar 12, 2016
2 parents 7aeadea + 5847f99 commit 092f798
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/date-picker/date-picker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ const DatePicker = React.createClass({
getInitialState() {
return {
date: this._isControlled() ? this._getControlledDate() : this.props.defaultDate,
dialogDate: new Date(),
muiTheme: this.context.muiTheme || getMuiTheme(),
};
},
Expand Down Expand Up @@ -221,9 +220,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);
}
},

/**
Expand Down

0 comments on commit 092f798

Please sign in to comment.