ProgressNS / nativescript-ui-feedback

This repository is used for customer feedback regarding Telerik UI for NativeScript. The issues system here is used by customers who want to submit their feature requests or vote for existing ones.
Other
115 stars 21 forks source link

RadCalendar - IOS : dateSelectedEvent called endlessly #1445

Open kriefsacha opened 4 years ago

kriefsacha commented 4 years ago

Please take a minute to read our NativeScript Code of Conduct before proceeding with posting issues or discussing. The purpose of this guide is to make communication and cooperation within our forums a pleasure for you and the other members.

Please, provide the details below:

Tell us about the problem

Please, ensure your title is less than 63 characters long and starts with a capital letter.

Hi. The problem i have is occuring on IOS only. With RadCalendar on day viewMode, i have the dateSelectedEvent to know when the user change the date and to go ask the API the event of that day. Then, when i have a response, i change my variable of eventSource to the new event, but this is causing to call the dateSelectedEvent another time, and then another time ...only when the observable from the API is returning events

Which platform(s) does your issue occur on?

Nativescript Angular !

iOS/Android/Both (if applicable tell us the specific version of the platform)

IOS only , i'm on tns-ios 6.2.0

Please provide the following version numbers that your issue occurs with:

Please tell us how to recreate the issue in as much detail as possible.

  1. Start the application
  2. Get events from the API
  3. See the console logs ("on date selected" and "on get events observable") write without ending when the observable is returning events

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

(You can paste entire code snippets, link to playground demo or attach a runnable project)

HTML:

<RadCalendar viewMode="Day" selectionMode="Single"
                    [eventSource]="calendarevents" (dateSelected)="dateSelectedEvent($event)">
                </RadCalendar>

TS:

export class HomeComponent implements OnInit {
    private calendarevents: Array<CalendarEvent>;
    private dbEvents: any[] = [];

    constructor(private calendarService: CalendarService, private router: Router, private loaderService: LoaderService, private ngZone: NgZone) {
    }

    ngOnInit(): void {
    }

    getEvents(startDate: Date, endDate: Date) {
        this.loaderService.show();

        this.calendarService.EventsTechnical(startDate, endDate).subscribe(res => {
            this.dbEvents = res.events;
            this.calendarevents = this.dbEvents.map(event => {
                return new CalendarEvent(event.extendedProperties.shared.SystemInterventionTypeLabel + " - " + event.extendedProperties.shared.location, new Date(event.start.dateTime), new Date(event.end.dateTime), false, new Color("#00B5BE"))
            });
            console.log("on get events observable");
            this.loaderService.hide();
        },
            err => {
                console.log(err);
                this.loaderService.hide();
                let options = {
                    title: localize('error'),
                    message: localize('error-description'),
                    okButtonText: localize('ok')
                };

                alert(options);
            });
    }

    dateSelectedEvent(event: CalendarSelectionEventData) {
        console.log("on date selected");
        let startDate = new Date(event.date);
        let endDate = new Date(event.date);
        endDate.setHours(23);
        endDate.setMinutes(59);
        endDate.setSeconds(59);
        this.getEvents(startDate, endDate);
    }
}
kriefsacha commented 4 years ago

I changed the event from dateSelected to navigatingToDateStarted, seems to work but i would like to know why it happens if that's possible