Angular-calendar: In month view the event container slider automatically opens for the current day even if no event scheduled

Created on 29 Mar 2019  路  3Comments  路  Source: mattlewis92/angular-calendar

Describe the bug

In month view the event container slider automatically opens (without any interaction) for the current day even if no event scheduled for that date.

Minimal reproduction of the problem with instructions

You can see the code where you can reproduce the issue:
https://stackblitz.com/edit/angular-calendar-month-view-empty-event-container

Reproduction steps

  1. Open the above mentioned StackBlitz example where the week view will be automatically activated. Click on the month view and you will see the slider below today automatically opens without any content.
  2. Another way is to modify the default calendar view in demo/component.ts on line 50 to CalendarView.Month. Refresh the page and you will see the appearance of the same issue.

Note
If you click on a day in month view where any event scheduled the action will open the event container slider of that day and the issue won't happen again as you cannot click on today.

Screenshots
today_without_event

Versions
angular-calendar 0.27.1
Chrome 73/Firefox 66 I think it is a browser independent problem.

Most helpful comment

Hey, so to remain as un-opinionated as possible, the calendar doesn't handle any business logic for opening and closing the open day events (sometimes people want it to open on no events so they can provide a custom template with a "Add new" button inside). Because you initialise the activeDayIsOpen to true it remains open. You can use the beforeViewRender hook though to add some custom logic to keep any days with 0 events closed:

beforeMonthViewRender(lastRender: CalendarMonthViewBeforeRenderEvent): void {
    lastRender.body.forEach(cell => {
      if (isSameDay(cell.date, this.viewDate) && cell.events.length === 0) {
        this.activeDayIsOpen = false;
        this.changeDetectorRef.detectChanges();
      }
    })
  }

Here's a working example: https://stackblitz.com/edit/angular-calendar-month-view-empty-event-container-fcmvld?file=demo%2Ftemplate.html

Hope that helps! 馃槃

Thank you for the effort to make this explanation. I just raised this issue because for me it seemed a little inconsistent the way it works. I mean basically you cannot click on a day which contains no events so the slider won't open. But the this.activeDayIsOpen overwrites this behavior and for me that worth to have this double check.

Anyway thank you very much for the answer.

All 3 comments

Thanks so much for opening an issue! If you'd like me to give priority to answering your issue or would just like to support this project, then please consider supporting me on Patreon

Hey, so to remain as un-opinionated as possible, the calendar doesn't handle any business logic for opening and closing the open day events (sometimes people want it to open on no events so they can provide a custom template with a "Add new" button inside). Because you initialise the activeDayIsOpen to true it remains open. You can use the beforeViewRender hook though to add some custom logic to keep any days with 0 events closed:

beforeMonthViewRender(lastRender: CalendarMonthViewBeforeRenderEvent): void {
    lastRender.body.forEach(cell => {
      if (isSameDay(cell.date, this.viewDate) && cell.events.length === 0) {
        this.activeDayIsOpen = false;
        this.changeDetectorRef.detectChanges();
      }
    })
  }

Here's a working example: https://stackblitz.com/edit/angular-calendar-month-view-empty-event-container-fcmvld?file=demo%2Ftemplate.html

Hope that helps! 馃槃

Hey, so to remain as un-opinionated as possible, the calendar doesn't handle any business logic for opening and closing the open day events (sometimes people want it to open on no events so they can provide a custom template with a "Add new" button inside). Because you initialise the activeDayIsOpen to true it remains open. You can use the beforeViewRender hook though to add some custom logic to keep any days with 0 events closed:

beforeMonthViewRender(lastRender: CalendarMonthViewBeforeRenderEvent): void {
    lastRender.body.forEach(cell => {
      if (isSameDay(cell.date, this.viewDate) && cell.events.length === 0) {
        this.activeDayIsOpen = false;
        this.changeDetectorRef.detectChanges();
      }
    })
  }

Here's a working example: https://stackblitz.com/edit/angular-calendar-month-view-empty-event-container-fcmvld?file=demo%2Ftemplate.html

Hope that helps! 馃槃

Thank you for the effort to make this explanation. I just raised this issue because for me it seemed a little inconsistent the way it works. I mean basically you cannot click on a day which contains no events so the slider won't open. But the this.activeDayIsOpen overwrites this behavior and for me that worth to have this double check.

Anyway thank you very much for the answer.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Sushma-tiwari picture Sushma-tiwari  路  3Comments

teodoramalec picture teodoramalec  路  4Comments

IterationCorp picture IterationCorp  路  5Comments

Herb-sh picture Herb-sh  路  4Comments

oldschoolbg picture oldschoolbg  路  4Comments