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

When using DatePicker.startDate, previous/next month navigation does not work #3178

Closed
dstj opened this issue May 6, 2019 · 2 comments · Fixed by #3179
Closed

When using DatePicker.startDate, previous/next month navigation does not work #3178

dstj opened this issue May 6, 2019 · 2 comments · Fixed by #3179

Comments

@dstj
Copy link

dstj commented May 6, 2019

Bug description:

When setting [startDate] on a DatePicker as specified in the doc, the navigation the previous or next month no longer work.

When using the alternative navigateTo(), it works.

Note: I can't navigateTo() because I want the datepicker in a ngbPopover (also in the repro)

Link to minimally-working StackBlitz that reproduces the issue:

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

Versions of Angular, ng-bootstrap and Bootstrap:

"@angular/core": "^7.2.5",
"@ng-bootstrap/ng-bootstrap": "^4.1.2",
"bootstrap": "^4.3.1",

@dstj dstj changed the title When using [startDate], previous/next month navigation does not work When using DatePicker.startDate, previous/next month navigation does not work May 6, 2019
@maxokorokov
Copy link
Member

Hey, @dstj!

As [startDate] is a binding and you're returning a new object every time from the getStartDate() method, you're forcing datepicker to go to this date every time change detection happens.

So if you were to return the same date object, you wouldn't have this issue:

https://stackblitz.com/edit/angular-r72dtz?file=src/app/app.component.ts

However I suppose we should compare the actual start date values inside the datepicker, not rely on object equality in this case.

@dstj
Copy link
Author

dstj commented May 7, 2019

@maxokorokov, right, I should have suspected that, my bad! I assumed somehow that there would be some kind of equality comparaison on the NgbDateStruct instead of only a reference check.

Thanks.

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

Successfully merging a pull request may close this issue.

2 participants