Skip to content

Commit

Permalink
fix(datepicker): avoid mutating value in daterangepicker (#6035)
Browse files Browse the repository at this point in the history
fixes #6034

Co-authored-by: Dmitriy Danilov <daniloff200@gmail.com>
  • Loading branch information
Romy Kusuma and daniloff200 authored Apr 5, 2021
1 parent 8bcc900 commit ca66023
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/datepicker/bs-daterangepicker-input.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ export class BsDaterangepickerInputDirective
}

validate(c: AbstractControl): ValidationErrors | null {
const _value: [Date, Date] = c.value;
let _value: [Date, Date] = c.value;
const errors: Record<string, unknown>[] = [];

if (_value === null || _value === undefined || !isArray(_value)) {
return null;
}

_value.sort((a, b) => a.getTime() - b.getTime());
_value = _value.slice().sort((a, b) => a.getTime() - b.getTime()) as [Date, Date];

const _isFirstDateValid = isDateValid(_value[0]);
const _isSecondDateValid = isDateValid(_value[1]);
Expand Down

0 comments on commit ca66023

Please sign in to comment.