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

useSortable's transform property returns null when reaching a certain point #1498

Open
christiangrothaus opened this issue Oct 8, 2024 · 4 comments

Comments

@christiangrothaus
Copy link

christiangrothaus commented Oct 8, 2024

I am attempting to create a horizontal sortable list but the transform property returns null when the draggable item reaches a certain point.

  • The key for the list of items is a unique ID that is persistent
  • The ID passed in useSortable is that same unique ID
  • Transform is returned as null at the same x coordinate for all items
  • The x coordinate where the items reset increases at a diminishing rate when adding more items
  • Once the list is long enough to go past the point where null is returned, null will still be returned but moving the cursor further causes the item to be picked back up
  • Changing the collision algorithm changes the distance at which transform returns as null
@christiangrothaus
Copy link
Author

christiangrothaus commented Oct 9, 2024

After more investigation I noticed that the container is being added to the list of collisions. This is when using the provided collision strategies.

@DubstepKnight
Copy link

I am experiencing a very similar issue, @christiangrothaus have you found a solution or a workaround?

@christiangrothaus
Copy link
Author

christiangrothaus commented Oct 21, 2024

I am experiencing a very similar issue, @christiangrothaus have you found a solution or a workaround?

I ended up creating a custom collision detection wrapper function. I wanted to use the closestCenter algorithm, so I extracted the droppabledRects property from the arguments, deleted the container from the map, and passed everything back to the provided algorithm.

const collisionAlgorithm: CollisionDetection = (args) => {
  const {
    active,
    collisionRect,
    droppableContainers,
    droppableRects,
    pointerCoordinates
  } = args;

  droppableRects.delete('container-id');

  return closestCenter({
    active,
    collisionRect,
    droppableContainers,
    droppableRects,
    pointerCoordinates
  });
};

@sno6
Copy link

sno6 commented Oct 30, 2024

I ran into a similar issue which was being caused by SortableContext.

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

No branches or pull requests

3 participants