Skip to content

Commit 43a0857

Browse files
committed
fix(pf3): stop date picker crash when value is string.
1 parent 7eb78d3 commit 43a0857

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

packages/pf3-component-mapper/demo/demo-schemas/sandbox.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ const output = {
431431
title: 'Datepicker with past days',
432432
component: components.DATE_PICKER,
433433
variant: 'date-time',
434+
initialValue: '2019-11-04T12:31:00.000Z',
434435
},
435436
],
436437
component: components.SUB_FORM,

packages/pf3-component-mapper/src/form-fields/date-time-picker/date-time-picker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class DateTimePicker extends React.Component {
3131
super(props);
3232
this.state = {
3333
positionLeft: 0,
34-
selectedDay: props.value,
34+
selectedDay: typeof props.value === 'string' ? new Date(props.value) : props.value,
3535
selectingMonth: false,
3636
selectingYear: false,
3737
isOpen: false,
@@ -169,7 +169,7 @@ DateTimePicker.propTypes = {
169169
showTodayButton: PropTypes.bool,
170170
isDisabled: PropTypes.bool,
171171
disabledDays: PropTypes.array,
172-
value: PropTypes.instanceOf(Date),
172+
value: PropTypes.oneOfType([ PropTypes.instanceOf(Date), PropTypes.string ]),
173173
closeOnDaySelect: PropTypes.bool,
174174
onChange: PropTypes.func.isRequired,
175175
isClearable: PropTypes.bool,

0 commit comments

Comments
 (0)