-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Datepicker: make navigation event cancellable #2913
Comments
@CarlosTorrecillas It might not be run for all months if you have multiple months visible though (it is run only for newly generated months)... is that the case for you? |
@maxokorokov thanks for the reply. It's strange as I added the I may be doing something wrong here but as far as I can see the navigate code gets run last? I have a basic calendar, don't have any multi-month or any other fancy customisation - pretty standard setup. You can simple click on the "next month" arrow to reproduce it. |
Oh, I didn't get what was the problem initially. Thought that Yes,
Sorry it's still unclear what is the problem/use case you're trying to solve |
Yeah, I think I miss the context here. When I click and Unless I'm understanding this wrong, perhaps there is another way of doing it? Thanks! |
Ok, so from what I understand, you want something like router data prefetchig with Resolver: https://angular.io/guide/router#resolve-pre-fetching-component-data → basically wait navigating until the promise is resolved. I think doing this would be an overkill for the datepicker. What we could do is to fire So for your use case:
/**
* The payload of the datepicker navigation event
*/
export interface NgbDatepickerNavigateEvent {
current: {year: number, month: number};
next: {year: number, month: number};
preventDefault: () => void;
} So will mark this as a feature request |
That's exactly what I need. Thanks for getting back to me. Appreciated |
Bug description:
markDisabled
is executed before thenavigate
callback in NgbDatePicker when changing month. If you want to apply some checks re the state of the days in terms of them being disabled then that's not possible.Link to minimally-working StackBlitz that reproduces the issue:
https://stackblitz.com/edit/datepicker-navigation
Versions of Angular, ng-bootstrap and Bootstrap:
Angular: 7.0.0
ng-bootstrap: 4.0.0
Bootstrap: -
I think this is pretty similar to #1325 and I could also use the workaround but in my case and in general we could make that event being run after the navigate.
I'm not sure if that would be a matter of reordering the lists:
https://github.com/ng-bootstrap/ng-bootstrap/blob/master/src/datepicker/datepicker.ts#L281
https://github.com/ng-bootstrap/ng-bootstrap/blob/master/src/datepicker/datepicker.ts#L289
And if you don't see any issues with that perhaps that could be a feature to have?
The text was updated successfully, but these errors were encountered: