Skip to content

Commit

Permalink
fix(datepicker): fixed infinite cycle behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
lexasq committed Oct 21, 2024
1 parent b56863d commit 4741422
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/datepicker/bs-datepicker-input.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ export class BsDatepickerInputDirective implements ControlValueAccessor, Validat
if (this._picker && this._picker.minDate && isBefore(_value, this._picker.minDate, 'date')) {
this.writeValue(this._picker.minDate);

return { bsDate: { minDate: this._picker.minDate } };
return this._picker.ignoreMinMaxErrors ? null : { bsDate: { minDate: this._picker.minDate } };
}

if (this._picker && this._picker.maxDate && isAfter(_value, this._picker.maxDate, 'date')) {
this.writeValue(this._picker.maxDate);

return { bsDate: { maxDate: this._picker.maxDate } };
return this._picker.ignoreMinMaxErrors ? null : { bsDate: { maxDate: this._picker.maxDate } };
}
}

Expand Down Expand Up @@ -194,7 +194,6 @@ export class BsDatepickerInputDirective implements ControlValueAccessor, Validat
}

this._picker.bsValue = this._value;
this._onChange(this._value);
}

setDisabledState(isDisabled: boolean): void {
Expand Down
4 changes: 4 additions & 0 deletions src/datepicker/bs-datepicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export class BsDatepickerDirective implements OnInit, OnDestroy, OnChanges, Afte
* Maximum date which is available for selection
*/
@Input() maxDate?: Date;
/**
* Ignore validation errors when you reset to minDate or maxDate
*/
@Input() ignoreMinMaxErrors?: boolean;
/**
* Minimum view mode : day, month, or year
*/
Expand Down

0 comments on commit 4741422

Please sign in to comment.