From 62e532218bf9bcae13a2a8d9446fc70de42a9a0d Mon Sep 17 00:00:00 2001 From: Ro Savage Date: Fri, 22 Apr 2016 15:34:48 +1200 Subject: [PATCH] Update DatePicker to handle being passed a value of an empty stirng --- components/date_picker/DatePicker.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/components/date_picker/DatePicker.js b/components/date_picker/DatePicker.js index 0ccc56e2..799e52ea 100644 --- a/components/date_picker/DatePicker.js +++ b/components/date_picker/DatePicker.js @@ -17,7 +17,10 @@ class DatePicker extends React.Component { maxDate: React.PropTypes.object, minDate: React.PropTypes.object, onChange: React.PropTypes.func, - value: React.PropTypes.object + value: React.PropTypes.oneOfType([ + React.PropTypes.instanceOf(Date), + React.PropTypes.string + ]) }; state = { @@ -41,7 +44,8 @@ class DatePicker extends React.Component { render () { const { inputClassName, value } = this.props; const inputFormat = this.props.inputFormat || time.formatDate; - const date = value ? inputFormat(value) : null; + const date = Object.prototype.toString.call(value) === '[object Date]' ? value : undefined; + const formattedDate = date === undefined ? inputFormat(value) : ''; return (
@@ -52,7 +56,7 @@ class DatePicker extends React.Component { label={this.props.label} readOnly type='text' - value={date} + value={formattedDate} />
);