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

Schedule has an infinite loop on the event. #2264

Closed
leetharris opened this issue Mar 10, 2017 · 8 comments
Closed

Schedule has an infinite loop on the event. #2264

leetharris opened this issue Mar 10, 2017 · 8 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@leetharris
Copy link

leetharris commented Mar 10, 2017

I'm submitting a ... (check one with "x")

[X ] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case (Bug Reports)

I am unable to reproduce this on a Plunkr as your Plunkr does not include FullCalendar and jQuery (needed dependencies for this issue).

Current behavior
On the latest version of PrimeNG (including the latest FullCalendar plugin), the (onViewRender) event loops constantly (edit ONLY when events are added to the schedule through the [events] attribute).

However, if I manually go into node_modules/primeng/schedule/ from the previous version and replace the entire contents of schedule.js, it returns to normal functionality and begins working.

There were obviously a lot of changes made to the schedule.js file (diff brings up ~250 adds/removes), so I suspect it has something to do with the new FullCalendar version OR the wrappers you've provided for it.

Expected behavior
The (onViewRender) event should only be called when the date changes or an action has taken place. In all previous versions this would be called when:

A: The component was being initialized.

B: The date was changed (either through methods or using the built-in interface).

Minimal reproduction of the problem with instructions
Put a <p-schedule (onViewRender)="testMethod($event)"> on your template. Add a method such as this to your component:

testMethod(e)
{
console.log(e);
}

You'll see that the method is called infinitely.

Please tell us about your environment:
OSX Sierra, 2016 MBP, Angular-CLI (latest version), Atom, VM running through Vagrant for backend.

  • Angular version: 2.4.5

  • PrimeNG version: 2.0.1

  • Browser: Chrome

  • Language: TypeScript 2.1.5

  • Node (for AoT issues): 6.9.4

@leetharris
Copy link
Author

I made a quick edit, it's not infinitely looping in all cases.

@cagataycivici cagataycivici self-assigned this Mar 10, 2017
@cagataycivici cagataycivici added the Status: Pending Review Issue or pull request is being reviewed by Core Team label Mar 10, 2017
@cagataycivici cagataycivici added this to the 4.0.RC1 milestone Mar 10, 2017
@cagataycivici cagataycivici changed the title Schedule (aka FullCalendar) has an infinite loop on the (onViewRender) event. Schedule has an infinite loop on the event. Mar 11, 2017
@cagataycivici cagataycivici removed the Status: Pending Review Issue or pull request is being reviewed by Core Team label Mar 11, 2017
@cagataycivici cagataycivici removed this from the 4.0.RC1 milestone Mar 11, 2017
@cagataycivici
Copy link
Member

I'm unable to replicate;

<button type="button" (click)="add($event)">Add</button>
    
    <p-schedule [events]="events" [header]="header" defaultDate="2017-02-01" [eventLimit]="4" [editable]="true"  (onViewRender)="testMethod($event)"></p-schedule>
    ngOnInit() {
        this.eventService.getEvents().then(events => {this.events = events;});
    }

    testMethod(e) {
        console.log('View');
    }
    
    add() {
        this.events.push({
            "id": 13,
            "title": "Click for Google",
            "url": "http://google.com/",
            "start": "2017-02-25"
        });
    }

When I click the add button it adds the event to the schedule and then changing view or date does not result in loop. Please provide a test case and we'll reopen.

@1guru
Copy link

1guru commented Mar 13, 2017

Hi,

The problem seems to be from setting the onViewRender event. If you need to reset your current event list it will go on an infinite loop. Is there another way to do this?

Here is a plunker to reproduce: http://plnkr.co/edit/2WMrT6euFd8WWzciKBrZ

@1guru
Copy link

1guru commented Mar 13, 2017

I have modified the way I reset the events and the infinite loop is gone: http://plnkr.co/edit/rbJxyvAU3Sxw4BHpiZwA

@cagataycivici cagataycivici reopened this Mar 13, 2017
@cagataycivici cagataycivici added the Status: Pending Review Issue or pull request is being reviewed by Core Team label Mar 13, 2017
@jacqueslareau
Copy link

Can confirm this behavior. Replacing the events list triggers another onViewRender event, causing infinite loop.

@jacqueslareau
Copy link

@1guru Trying to access your plunker and its stuck on Loading? Weird. Can you post here how you prevented the infinite loop?

@1guru
Copy link

1guru commented Mar 13, 2017

@jacqueslareau instead of reinitializing the events array, I have removed the elements from it:

export class AppComponent {
  events: any[]=[];
  
  loadEvents(event) {
    console.log(event);
    this.events.splice(0, this.events.length);
    this.events.push({
      start: "2017-03-20",
      end: "2017-03-21",
    });
  }
}

@cagataycivici cagataycivici added this to the 4.0.RC2 milestone Mar 17, 2017
@cagataycivici
Copy link
Member

I've replicated

@cagataycivici cagataycivici added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Pending Review Issue or pull request is being reviewed by Core Team labels Mar 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

4 participants