search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Daypilot navigator problem after updating to angular 16

Asked by Giorgio
1 month ago.

Good morning,

After the update the calendar behaves strangely, if I select dates in the console I get the error "Cannot read properties of null (reading 'month')" and if I continue with the months, suddenly from 2024 it seems like 2030. Does anyone know why? I don't understand where month is not reading this variable.

Comment posted by Giorgio
1 month ago.

the problem seems to be linked to the freeHandSelectionEnabled property... if I disable it everything works correctly. Is it a bug or am I configuring something wrong?

"config": {

"selectMode": "Day",

"freeHandSelectionEnabled": false,

"skipMonths": 3,

"showMonths": 3,

"orientation": "Horizontal"

}

Answer posted by Dan Letecky [DayPilot]
1 month ago.

This is hard to guess without the actual code, but you may be accessing an instance that has been destroyed already.

If it doesn’t help, could you please post an example that reproduces the problem?

Comment posted by Dan Letecky [DayPilot]
1 month ago.

You can also take a look at this reference implementation:

Comment posted by Giorgio
1 month ago.

I did other tests and the problem seems to be specific to the case in which I set orientation:horizontal.. I can no longer select from one month to the next. Very strange behavior. I'm using the basic component, nothing custom

Comment posted by Dan Letecky [DayPilot]
1 month ago.

This configuration seems to work fine for me (horizontal orientation, selecting a range over months, DayPilot Pro for JavaScript 2024.3.5981). Angular 16, but that shouldn’t make any difference.

import {Component, ViewChild} from "@angular/core";
import {
  DayPilot,
  DayPilotCalendarComponent,
  DayPilotNavigatorComponent
} from "daypilot-pro-angular";

@Component({
  selector: 'calendar-component',
  template: `
    <div class="container">
      <div class="navigator">
        <daypilot-navigator [config]="configNavigator" [events]="events" #navigator></daypilot-navigator>
      </div>
      <div class="content">
        <daypilot-calendar [config]="configCalendar" [events]="events" #calendar></daypilot-calendar>
      </div>
    </div>

  `,
  styles: [`
    .container {
      display: flex;
      flex-direction: row;
    }

    .navigator {
      margin-right: 10px;
    }

    .content {
      flex-grow: 1;
    }
  `]
})
export class CalendarComponent {

  @ViewChild("calendar") calendar!: DayPilotCalendarComponent;
  @ViewChild("navigator") nav!: DayPilotNavigatorComponent;

  events: DayPilot.EventData[] = [];

  configNavigator: DayPilot.NavigatorConfig = {
    showMonths: 3,
    cellWidth: 25,
    cellHeight: 25,
    selectMode: "Day",
    orientation: "Horizontal",
    freeHandSelectionEnabled: true,
    onVisibleRangeChanged: args => {
    },
    onTimeRangeSelected: args => {
      this.configCalendar.viewType = "Days";
      this.configCalendar.startDate = args.start;
      this.configCalendar.days = args.days;
    }
  };

  configCalendar: DayPilot.CalendarConfig = {
    viewType: "Days",
    onTimeRangeSelected: async (args) => {
      const modal = await DayPilot.Modal.prompt("Create a new event:", "Event 1");
      const dp = args.control;
      dp.clearSelection();
      if (!modal.result) { return; }
      dp.events.add(new DayPilot.Event({
        start: args.start,
        end: args.end,
        id: DayPilot.guid(),
        text: modal.result
      }));
    }
  };

}
Comment posted by Giorgio
1 month ago.

I'll have to try updating the daypilot version. It seems that in version 2023.2.5556 there is no way to use it horizontally without that problem

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.