Skip to content

Commit

Permalink
fix: improve handling of datepicker when in invalid state #99
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanjones243 committed Feb 1, 2023
1 parent 684c9c2 commit 2f4a9db
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/auro-datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,28 @@ class AuroDatePicker extends LitElement {
this.validate();
}

if (changedProperties.has('minDate')) {
if (this.minDate && this.value) {
if (new Date(this.minDate).getTime() > new Date(this.value).getTime()) {
this.value = undefined;
this.input.value = undefined;
this.centralDate = this.value;
this.calendar.selectedDate = undefined;
}
}
}

if (changedProperties.has('maxDate')) {
if (this.maxDate && this.value) {
if (new Date(this.maxDate).getTime() < new Date(this.value).getTime()) {
this.value = undefined;
this.input.value = undefined;
this.centralDate = this.value;
this.calendar.selectedDate = undefined;
}
}
}

if (changedProperties.has('centralDate')) {
this.calendar.centralDate = new Date(this.centralDate);
}
Expand Down

0 comments on commit 2f4a9db

Please sign in to comment.