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

Dragged item disappears on scroll up/down #41

Closed
xiom84 opened this issue Jul 1, 2024 · 6 comments · Fixed by #43
Closed

Dragged item disappears on scroll up/down #41

xiom84 opened this issue Jul 1, 2024 · 6 comments · Fixed by #43

Comments

@xiom84
Copy link

xiom84 commented Jul 1, 2024

Hi,

when i drag an item and scroll down or up the dragged item disappears when the movement is larger than the timeline height.

image
@samuelarbibe
Copy link
Owner

Hey, on what exact example are you experiencing it? And are you using virtualization?

@xiom84
Copy link
Author

xiom84 commented Jul 2, 2024

For example here directly on the demo page: https://www.dnd-timeline.com/

Yes you are right it seems to be the virtualization examples which are failing.
-> https://dnd-timeline-virtual.vercel.app/

(I tried another computer and different browsers (firefox, chrome) with the same result.)

@samuelarbibe
Copy link
Owner

Ok, so here is the deal:
When using tanstack/virtual, only rows that are in the visible area are rendered.
This means, that when an item is dragged from a visible row, and that row becomes invisible because of scrolling, that row will unmount and the item itself will unmount as well.

The solution comes from @tanstack/virtual:
https://tanstack.com/virtual/latest/docs/api/virtualizer#rangeextractor
You can help the library understand which rows should and shouldn't be rendered by using the rangeExtractor props, and make sure the library never unmounts a row whose item is currently being dragged.

Anyway, I will make sure to implement this fix in the example and demo page ASAP, and update you.

@xiom84
Copy link
Author

xiom84 commented Jul 2, 2024

Sounds fantastatic

Thanks for the incredible fast solution.

@samuelarbibe
Copy link
Owner

Fixed! the demo page will be fixed as well soon.
Check out the code for the "virtual" example, it should help you.

https://dnd-timeline-virtual.vercel.app

@xiom84
Copy link
Author

xiom84 commented Jul 3, 2024

Perfect thanks, that helps a lot.

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

Successfully merging a pull request may close this issue.

2 participants