valor-software / ngx-bootstrap

Fast and reliable Bootstrap widgets in Angular (supports Ivy engine)
https://valor-software.com/ngx-bootstrap
MIT License
5.53k stars 1.69k forks source link

BsDatepicker config "keepDatesOutOfRules: true" only works with bsValue but not with ngModel or reactive forms #6570

Open gehrmanng opened 1 year ago

gehrmanng commented 1 year ago

Bug description: When using BsDatepicker with a minDate, the configuration option "keepDatesOutOfRules: true" only works when the datepicker value is set by [bsValue]. When using Angular Forms [(ngModel)] or Angular Reactive Forms formControlName="..." instead, an invalid date value gets overwritten by the configured minDate.

Plunker/StackBlitz that reproduces the issue: Please find a working demo project here: https://github.com/gehrmanng/bs-datepicker-test and a StackBlitz here: https://stackblitz.com/edit/github-4ravqg

Versions of ngx-bootstrap, Angular, and Bootstrap:

ngx-bootstrap: 10.3.0 Angular: 15.2.0 Bootstrap: 5.2.3

Build system: Angular CLI / NPM

Expected behavior I would expect the datepicker to keep the invalid date value when the "keepDatesOutOfRules" option is set to true.

VirendraMaheta7 commented 1 year ago

Can we have the working example of the solution with reactive form in stackblitz?

rahul71 commented 9 months ago

Seeing the same problem. Cant use [(ngModel)] with keepDatesOutOfRules: true and minDate

here is a working stackblitz of the issue. https://stackblitz.com/~/github.com/rahul71/ngx-datepicker-demo @VirendraMaheta7 ^ @gehrmanng ^

Any help would be appreciated.