Skip to content

Commit

Permalink
[TimePicker] update on defaultTime new prop.
Browse files Browse the repository at this point in the history
If a TimePicker instance is already mounted and a new defaultTime is passed to it, the `time` state value doesn't update.

There was already a pull request aiming to fix this and other issues for this component at mui#2027, but it has been waiting for review since Nov 24, 2015.
  • Loading branch information
rscnt committed Jan 29, 2016
1 parent e12a66c commit 301f5fa
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/time-picker/time-picker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ const TimePicker = React.createClass({
muiTheme: this.context.muiTheme || getMuiTheme(),
};
},

componentWillReceiveProps(nextProps, nextContext) {
const newState = this.state;
if (nextContext.muiTheme) {
newState.muiTheme = nextContext.muiTheme;
}
if (!Date.isEqualTime(this.state.time, nextProps.defaultTime)) {
newState.time = nextProps.defaultTime;
}
this.setState(newState);
},

windowListeners: {
'keyup': '_handleWindowKeyUp',
Expand Down

0 comments on commit 301f5fa

Please sign in to comment.