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

onTimeChange called before onItemDrag #838

Open
atheck opened this issue Oct 13, 2021 · 5 comments
Open

onTimeChange called before onItemDrag #838

atheck opened this issue Oct 13, 2021 · 5 comments

Comments

@atheck
Copy link

atheck commented Oct 13, 2021

Describe the bug

When dragging an item, onTimeChange is called just before onItemDrag. This happens only randomly.

In my case this unnecessarily causes reloading of data. When this happens, the moved item gets "recreated" and jumps back to the start position before dragging.

To Reproduce

<Timeline
    groups={groups}
    items={items}
    onItemDrag={() => console.log("onItemDrag")}
    onTimeChange={() => console.log("onTimeChange")}
/>

Sometimes this will print:

onTimeChange
onItemDrag

Expected behavior

onTimeChange should not be called before dragging an item.

Library Version

"react-calendar-timeline": "0.27.0"

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Firefox, Chrome
  • Version: latest
@atheck atheck changed the title onTimeChanged called before onItemDrag onTimeChange called before onItemDrag Oct 13, 2021
@Ilaiwi
Copy link
Collaborator

Ilaiwi commented Nov 8, 2021

@atheck this happens because how the library is implemented it's hard to distinguish between a select and drag an item vs dragging the timeline to scroll.
Please feel free to submit a PR with a fix for this issue.

@tejastomarbyte
Copy link

I would like to fix this issue, but I am just starting with open source. Can someone please guide on this ?

@pancholipratham7
Copy link

Hey I want to contribute to this issue can you please assign this task to me

@DanielDerma
Copy link

i made a solution: PR: #893

@ShabinMuhammedKK
Copy link

Add conditions to trigger onTimeChange only when there's a meaningful change in the timeline (i.e., not during a drag)

const handleTimeChange = () => {
if (!isDragging) {
console.log("onTimeChange");
}
};

<Timeline
groups={groups}
items={items}
onItemDrag={() => {
setIsDragging(true);
console.log("onItemDrag");
}}
onTimeChange={handleTimeChange}
/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants