Skip to content

Commit

Permalink
Fixes palantir#1402 time picker change clears data picker
Browse files Browse the repository at this point in the history
  • Loading branch information
cathyxz committed Aug 20, 2017
1 parent 6aff221 commit 3635ee6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions packages/datetime/examples/dateTimePickerExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ export class DateTimePickerExample extends BaseExample<{ date: Date }> {
}

private handleDateChange = (date: Date) => this.setState({ date });

}
18 changes: 10 additions & 8 deletions packages/datetime/src/dateTimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,16 @@ export class DateTimePicker extends AbstractComponent<IDateTimePickerProps, IDat
}

public componentWillReceiveProps(nextProps: IDatePickerProps) {
if (nextProps.value != null) {
this.setState({
dateValue: nextProps.value,
timeValue: nextProps.value,
});
} else {
// clear only the date to remove the selected-date style in the calendar
this.setState({ dateValue: null });
if (this.props.value != nextProps.value) {
if (nextProps.value != null) {
this.setState({
dateValue: nextProps.value,
timeValue: nextProps.value,
});
} else {
// clear only the date to remove the selected-date style in the calendar
this.setState({ dateValue: null });
}
}
}

Expand Down

0 comments on commit 3635ee6

Please sign in to comment.