stimulus-sortable icon indicating copy to clipboard operation
stimulus-sortable copied to clipboard

Makes A Request When An Item Is Dropped In Its Original Location

Open MatthewKennedy opened this issue 1 year ago • 4 comments

With the current implementation there is no check in place to see if the new location and old location are the same, if so do nothing.

This avoids server requests if someone grabs and then drops an item without moving it to a new location.

MatthewKennedy avatar Jul 19 '22 22:07 MatthewKennedy

Maybe we should use onUpdate instead of onEnd as default callback?

guillaumebriday avatar Jul 21 '22 09:07 guillaumebriday

As a workaround you can override the controller with something like this I guess in the options:

{ 
  onUpdate: this.end
}

guillaumebriday avatar Jul 21 '22 09:07 guillaumebriday

I'll try that out, comparing newIndex and oldIndex might cause an issue if someone moves an item to a new parent, indexes could be the same but it is actually a move.

MatthewKennedy avatar Jul 21 '22 09:07 MatthewKennedy

Yep, that is why I think using onUpdate might be the right solution because Sortable will only trigger the callback is the position actually change 🤔 didn't try it yet though

guillaumebriday avatar Jul 21 '22 09:07 guillaumebriday

Changed in https://github.com/stimulus-components/stimulus-sortable/releases/tag/v4.0.0

Thanks @MatthewKennedy

guillaumebriday avatar Oct 31 '22 14:10 guillaumebriday