namespace-ee / react-calendar-timeline

A modern and responsive react timeline component.
MIT License
1.93k stars 625 forks source link

Items rendering either after window resize or by pressing f12 #871

Open Himanshupal0001 opened 2 years ago

Himanshupal0001 commented 2 years ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce

Please provide one or both of the following:

Code (If you have a branch somewhere that shows your issue) or link to codesandbox example. Here's a base template for this library:

OR

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Library Version Please provide version of library in which this bug is occurring.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

Himanshupal0001 commented 2 years ago

Here's before and after pictures

Before image

After image

jonandernovella commented 2 years ago

I can reproduce this by passing a React state variable to the groups. However, if I pass a normal array then it works as expected.

clemencestr commented 2 years ago

I have the same problem on Mozilla, but it does not appear on Google Chrome or Safari.

Himanshupal0001 commented 2 years ago

I have the same problem on Mozilla, but it does not appear on Google Chrome or Safari.

I tried in all the browsers and the issue still persist.

Himanshupal0001 commented 2 years ago

I can reproduce this by passing a React state variable to the groups. However, if I pass a normal array then it works as expected.

Yeah, If A normal array is passed it works fine {if the value provided already rather fetched from the backend}. Do you have any idea how to resolve this? I tried normal arrays rather than states but the issue still persists.

baatten commented 2 years ago

what does a normal array mean? I have this bug even with demo example. anyone know how to resolve it?

fsuk commented 1 year ago

After spending an afternoon with this issue I have found that the issue occurrs when groups/items is undefined such as you might get if using useState before it is set.

To fix this I changed my code to check if groups and items are set before rendering:

 {groups && items &&     
        <Timeline
          groups={groups}
          items={items}
          ...
        />
      }

More detail: This seems to be a bug in the ScrollElement with thescrollComponent.scrollLeft being 0 initially until after the Timeline is resized.