StephenChou1017 / react-big-scheduler

A scheduler and resource planning component built for React and made for modern browsers (IE10+)
https://stephenchou1017.github.io/scheduler/#/
MIT License
754 stars 414 forks source link

[BUG] Order of events cause them not to be rendered in certain cases #138

Closed ThomasCarca closed 5 years ago

ThomasCarca commented 5 years ago

Hello ! Thank you very much for this great project, I find it very useful !

I'm running into a bug when overlapping events in a certain order.

Imagine having two events

const e1 = {
  id: 1,
  start: "2017-12-18 09:30:00",
  end: "2017-12-18 12:30:00",
  resourceId: "r1",
  title: "A"
};

const e2 = {
  id: 2,
  start: "2017-12-18 11:00:00",
  end: "2017-12-18 14:30:00",
  resourceId: "r1",
  title: "B"
};

for the following resource :

const r1 = [
  {
    id: "r1",
    name: "Resource1"
  }
];

Passing the events in the following order works as espected : [e1, e2] react-big-scheduler-bug-1

But if you pass the events in this order : [e2, e1] react-big-scheduler-bug-2

... you can see event B is not rendered. It reappears once you move event e1, though.

I have no idea what could cause this behavior.

A workaround I've found for now that is not ideal is to sort the events by starting date. This seems to resolve the issue.

Here is a Code Sandbox that showcases the issue

StephenChou1017 commented 5 years ago

@ThomasCarca Hi, it's designed like that. The event array set to the SchedulerData should be sorted in ascending order by event.start property, otherwise there will be many rendering errors in the Scheduler component.

ThomasCarca commented 5 years ago

Hi, thanks for the quick answer. Cool to know it's not a bug. Is it specified somewhere in the docs?

StephenChou1017 commented 5 years ago

Yes, in the README.md

ThomasCarca commented 5 years ago

Ah yes, indeed. Thanks !