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

Question: Can sortable items render different sizes on drag start? #544

Closed
jquense opened this issue Dec 14, 2021 · 5 comments · Fixed by #561
Closed

Question: Can sortable items render different sizes on drag start? #544

jquense opened this issue Dec 14, 2021 · 5 comments · Fixed by #561
Assignees
Labels
enhancement New feature or request

Comments

@jquense
Copy link

jquense commented Dec 14, 2021

👋 thanks for awesome library, really enjoying it. A pattern that we'd to implement for sortable lists where the items are variable (sometimes long) heights in potential tall lists is to have items display as a smaller (maybe constant height) version of themselves when dragging starts. The question is whether this is possible with dndkit, and if so what hooks need to be used to make it happen. My initial attempts haven't being very fruitful because it appears that onDragStart is too late to change the shapes of items.

@HelKyle
Copy link

HelKyle commented Dec 14, 2021

To better understand what problems you are facing, could you provide a CodeSandbox demo link?

@jquense
Copy link
Author

jquense commented Dec 14, 2021

Here is one, where the issue is likely the transition makes the initial measurement incorrect: https://codesandbox.io/s/dnd-kit-sortable-forked-zpfng?file=/src/Item.jsx

I am actually still trying to understand why i'm seeing worse behavior in our app vs the codesandbox, i think it's related to multiple containers, will investigate

@clauderic
Copy link
Owner

clauderic commented Jan 7, 2022

@jquense the problem with your example is indeed the transition, @dnd-kit measures items right after dragging begins, but since you have a transition applied on the height changes, the height is incorrect at the point in time where it is measured.

As a temporary workaround, you can disable the height transition and it should work fine.

This is something I'm working on fixing in this PR #561

@clauderic clauderic added the enhancement New feature or request label Jan 7, 2022
@clauderic clauderic self-assigned this Jan 7, 2022
@clauderic clauderic linked a pull request Jan 7, 2022 that will close this issue
@clauderic
Copy link
Owner

This should now be fixed in the latest releases of @dnd-kit

@Akash187
Copy link

I think I am facing the same error.

Screen.Recording.2023-01-25.at.4.13.24.AM.mov

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

Successfully merging a pull request may close this issue.

4 participants