From 301f5fa85e79543884cda1b28ddf7a54c8559db1 Mon Sep 17 00:00:00 2001 From: Raul Ascencio Date: Fri, 29 Jan 2016 17:41:50 -0600 Subject: [PATCH] [TimePicker] update on defaultTime new prop. 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 callemall/material-ui#2027, but it has been waiting for review since Nov 24, 2015. --- src/time-picker/time-picker.jsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/time-picker/time-picker.jsx b/src/time-picker/time-picker.jsx index f4e0557d3fa798..5f155a715aa3ba 100644 --- a/src/time-picker/time-picker.jsx +++ b/src/time-picker/time-picker.jsx @@ -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',