Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BsDatepicker min-max dates not react on resetting #3085

Closed
timaxapa opened this issue Nov 21, 2017 · 2 comments · Fixed by #3112
Closed

BsDatepicker min-max dates not react on resetting #3085

timaxapa opened this issue Nov 21, 2017 · 2 comments · Fixed by #3112

Comments

@timaxapa
Copy link

timaxapa commented Nov 21, 2017

Bug description or feature request:

Once defined minDate or maxDate for bsDatepicker there is no way to reset them

Plunker/StackBlitz that reproduces the issue:

https://stackblitz.com/edit/angular-r6jvsg

Versions of ngx-bootstrap, Angular, and Bootstrap:

ngx-bootstrap: 2.0.0-beta.8
Angular: 4 or 5
Bootstrap: 3.3

Build system: Angular CLI, System.js, webpack, starter seed:

Angular CLI: 1.4

Workaround:
Custom wrapper with code

    if (changes.minDate && !changes.minDate.isFirstChange() && !this.minDate) {
      this.minDate = new Date(0);
    }
    if (changes.maxDate && !changes.maxDate.isFirstChange() && !this.maxDate) {
      this.maxDate = new Date(8640000000000000);
    }

I am sexy and I know it

@valorkin
Copy link
Member

indeed

    this._config = Object.assign({}, this._config, this.bsConfig, {
      value: this._bsValue,
      isDisabled: this.isDisabled,
      minDate: this.minDate || this._config.minDate,
      maxDate: this.maxDate || this._config.maxDate
    });

this overwrites config values and have a fallback to them

@valorkin
Copy link
Member

it should be enough to remove || this._config.minDate, and maxDate and will work as expected
nice reason for small PR
this code repeats in date and range picker :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants