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

[bug] onMove return value not being respected #290

Open
james-ritchey opened this issue Jan 14, 2024 · 0 comments
Open

[bug] onMove return value not being respected #290

james-ritchey opened this issue Jan 14, 2024 · 0 comments

Comments

@james-ritchey
Copy link

Describe the bug
I have sortable items set up with different class names, including bookend-start and bookend-end, and the goal is to keep those items at the start and end of the list respectively. Using the onMove function we return the values shown in the docs to add the item before or after the related object, and while returning false works for cancelling the move, returning either 1 or -1 doesnt seem to have any affect, the dragged item is still dropped in the default direction.

To Reproduce
Steps to reproduce the behavior:

  1. Create a sortable list with multiple items, including one with a class name like bookend-end
  2. Use the following function as the onMove for the sortable list
  const relatedClass = e.related.classList
    if (relatedClass.contains('sortable-fixed')) {
      return false
    }
    if (relatedClass.contains('bookend-start')) {
      return 1
    }
    if (relatedClass.contains('bookend-end')) {
      return -1
    } return true
  }
  1. Drag an item around the bookend, the item should still drop on either side, not just the side related to the returned integer

Expected behavior
When we return 1 or -1 to the onMove, the dragged item be added only after or before the related item respectively.

Information

Versions - Look in your package.json for this information:
"react-sortablejs": "^6.1.4",
"react": "^18.2.0",

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

1 participant