Skip to content

[feature] Request: Add evt.related for onEnd() and onChange() like for onMove() #2435

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

Open
WoofGrrrr opened this issue Mar 29, 2025 · 0 comments

Comments

@WoofGrrrr
Copy link

As I understand it from reading the documentation, and some trial-and-error, it appears that the evt object passed to the onMove() function includes the evt.related property, providing a nice reference to the list item over which the dragged item is dragging.

I would find it even more useful if the evt object passed to the onEnd() and onChange() functions - called when dragging has finally ended and the list order has actually changed, I believe - so that the onEnd() and onChange() functions were to have a very nice reference to the item that was required to move in order to allow the dragged item to take its place.

One could say that evt.newIndex would help. Is it guaranteed that evt.newIndex + 1 is the index of the item that was moved? Perhaps not if the evt.newIndex is at the end of the list. But maybe that's okay, I guess you can test for that. Perhaps I should bring this up in a Discussion thread instead?

Anyway, a reference to the related (passively moved) item would be fantastic. To me it would be far more useful than the evt.related reference that is passed to onMove().

Perhaps better than using than using newIndex to use the DOM to get the correct child element in the list. It would seem to me that Sortable would already have a reference to the item in order to move it.

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