Skip to content

Commit

Permalink
Fixes mui#441
Browse files Browse the repository at this point in the history
DatePicker onChange should be onChangeDate
  • Loading branch information
EugeneZ committed Feb 4, 2016
1 parent 29670fe commit 776f27d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class DatePickerExampleControlled extends React.Component {
};
}

_handleChange = (event, date) => {
_handleChange = (date) => {
this.setState({
controlledDate: date,
});
Expand All @@ -22,7 +22,7 @@ export default class DatePickerExampleControlled extends React.Component {
<DatePicker
hintText="Controlled Date Input"
value={this.state.controlledDate}
onChange={this._handleChange}
onChangeDate={this._handleChange}
/>
);
}
Expand Down
15 changes: 10 additions & 5 deletions src/date-picker/date-picker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@ const DatePicker = React.createClass({
mode: React.PropTypes.oneOf(['portrait', 'landscape']),

/**
* Callback function that is fired when the date value changes. Since there
* is no particular event associated with the change the first argument
* will always be null and the second argument will be the new Date instance.
* Callback function that is fired when the date value changes.The first argument
* will be the selected Date instance.
*/
onChange: React.PropTypes.func,
onChangeDate: React.PropTypes.func,

/**
* Fired when the datepicker dialog is dismissed.
Expand Down Expand Up @@ -242,10 +241,14 @@ const DatePicker = React.createClass({
date: date,
});
}
if (this.props.onChange) this.props.onChange(null, date);
if (this.props.onChangeDate) this.props.onChangeDate(date);
if (this.props.valueLink) this.props.valueLink.requestChange(date);
},

_handleInputChange(e, value) {
if (this.props.onChangeDate) this.props.onChangeDate(value);
},

_handleInputFocus(e) {
e.target.blur();
if (this.props.onFocus) this.props.onFocus(e);
Expand Down Expand Up @@ -298,6 +301,7 @@ const DatePicker = React.createClass({
textFieldStyle,
valueLink,
firstDayOfWeek,
onChangeDate,
...other,
} = this.props;

Expand All @@ -310,6 +314,7 @@ const DatePicker = React.createClass({
value={this.state.date ? formatDate(this.state.date) : undefined}
onFocus={this._handleInputFocus}
onTouchTap={this._handleInputTouchTap}
onChange={this._handleInputChange}
/>
<DatePickerDialog
container={container}
Expand Down

0 comments on commit 776f27d

Please sign in to comment.