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

NgbDatepicker: infinite loop when using Date object with datepicker toggle #1062

Closed
jacqueslareau opened this issue Nov 18, 2016 · 3 comments

Comments

@jacqueslareau
Copy link

Bug description:

Browser crash/full cpu/infinite loop when setting model as new Date() and toggling the datepicker popup.

CAREFUL : See plunkr and click the button for the toggle, will have to restart script/tab/browser.

Checked on Firefox and Chrome.

Link to minimally-working plunker that reproduces the issue:

http://plnkr.co/edit/z4FuG5CXzalen5BFV9Cc?p=preview

Version of Angular, ng-bootstrap, and Bootstrap:

Angular: 2.2.1

ng-bootstrap: 1.0.0-alpha.13

Bootstrap: v4-alpha

@CrustyJew
Copy link

I just encountered this same issue a different way, by providing a year with no month and it causes the same loop. I've submitted a pull request (#1063) that resolves this issue by defaulting the month to 1.

@Thommas
Copy link

Thommas commented Dec 15, 2016

Just got this issue.

It's really surprising ! I just copy pasta the documentation and end up with my Google Chrome freezed. Quite dangerous.

I see fixes are waiting to be merged. Looking forward to it.

For now, I know the problem is caused when ngModel date is invalid, I will make sure it won't happen by filtering the ngModel date format validity myself.

@leonardoampuero
Copy link

I had that problem, I was setting the default date wrongly.

ngOnInit() {
const now = new Date();
const since = moment().subtract(14,'d').toDate();

this.model.fechaHasta = {year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate()};
this.model.fechaDesde = {year: since.getFullYear(), month: since.getMonth() + 1, day: since.getDate()};

}

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

No branches or pull requests

5 participants