Skip to content

Commit

Permalink
fix: make sure we only fire the on_change event if the date is valid
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker committed May 21, 2019
1 parent 609bde9 commit 15007ac
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/dnb-ui-lib/src/components/date-picker/DatePickerInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,14 @@ export default class DatePickerInput extends PureComponent {
}

callOnChange = ({ startDate, endDate }, onState = null) => {
if (typeof startDate !== 'undefined') {
if (
typeof startDate !== 'undefined' &&
DatePickerInput.isValidDate(startDate)
) {
this.setState(
{
startDate
// ,_listenForPropChanges: false
startDate,
_listenForPropChanges: false
},
onState
)
Expand All @@ -170,11 +173,14 @@ export default class DatePickerInput extends PureComponent {
})
}
}
if (typeof endDate !== 'undefined') {
if (
typeof endDate !== 'undefined' &&
DatePickerInput.isValidDate(endDate)
) {
this.setState(
{
endDate
// , _listenForPropChanges: false
endDate,
_listenForPropChanges: false
},
onState
)
Expand Down

0 comments on commit 15007ac

Please sign in to comment.