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

fix: use custom autoscroll with virtualization #43

Merged
merged 1 commit into from
Jul 2, 2024

Conversation

samuelarbibe
Copy link
Owner

This issue resolves items disappearing when dragging them out of the current viewport when using virtualization.

Solved #41 :

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.

Using dnd-kit's default autoscroll didn't work, so I implement my own useAutoscroll hook to scroll when dragged item is close to the container's edges.

@samuelarbibe samuelarbibe linked an issue Jul 2, 2024 that may be closed by this pull request
Copy link

vercel bot commented Jul 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
dnd-timeline-external ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 2, 2024 8:03pm
dnd-timeline-sortable ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 2, 2024 8:03pm
dnd-timeline-virtual ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 2, 2024 8:03pm

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 this pull request may close these issues.

Dragged item disappears on scroll up/down
1 participant