Skip to content

Commit 73a2ed9

Browse files
fix(date-picker): manage to reselect date while closing calendar (#2845)
Co-authored-by: Akshat Patel <38994122+Akshat55@users.noreply.github.com>
1 parent 17289f5 commit 73a2ed9

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

src/datepicker/datepicker.component.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -269,18 +269,11 @@ export class DatePicker implements
269269
// This makes sure that the `flatpickrInstance selectedDates` are in sync with the values of
270270
// the inputs when the calendar closes.
271271
if (this.range && this.flatpickrInstance) {
272-
if (this.flatpickrInstance.selectedDates.length !== 2) {
273-
// we could `this.flatpickrInstance.clear()` but it insists on opening the second picker
274-
// in some cases, so instead we do this
275-
this.setDateValues([]);
276-
this.doSelect([]);
277-
return;
278-
}
279272
const inputValue = this.input.input.nativeElement.value;
280273
const rangeInputValue = this.rangeInput.input.nativeElement.value;
281274
if (inputValue || rangeInputValue) {
282275
const parseDate = (date: string) => this.flatpickrInstance.parseDate(date, this.dateFormat);
283-
this.setDateValues([parseDate(inputValue), parseDate(rangeInputValue)]);
276+
this.setDateValues([parseDate(inputValue), parseDate(rangeInputValue || inputValue)]);
284277
this.doSelect(this.flatpickrInstance.selectedDates);
285278
}
286279
}

0 commit comments

Comments
 (0)