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

onMove incompatible with SortableJs #90

Open
nopeless opened this issue Aug 20, 2023 · 1 comment
Open

onMove incompatible with SortableJs #90

nopeless opened this issue Aug 20, 2023 · 1 comment

Comments

@nopeless
Copy link

emit('onMove') does not have the desirable effect

In SortableJs, you are able to cancel a move by returning a value from onMove() call. However, because of the way the code is implemented right now, this functionality is completely disabled.

sortable.value = new Sortable(newDraggable, {
...props.options,
onChoose: (event) => emit("choose", event),
onUnchoose: (event) => emit("unchoose", event),
onStart: (event) => {
isDragging.value = true;
emit("start", event);
},
onEnd: (event) => {
// This is a hack to move the event to the end of the event queue.
// cf this issue: https://github.com/SortableJS/Sortable/issues/1184
setTimeout(() => {
isDragging.value = false;
emit("end", event);
});
},
onAdd: (event) => emit("add", event),
onUpdate: (event) => emit("update", event),
onSort: (event) => emit("sort", event),
onRemove: (event) => emit("remove", event),
onFilter: (event) => emit("filter", event),
// See https://github.com/MaxLeiter/sortablejs-vue3/pull/56 for context on `attrs`.
onMove: (event, originalEvent) => "onMoveCapture" in attrs ? (<(event: Sortable.MoveEvent, originalEvent: Event) => void>attrs.onMoveCapture)(event, originalEvent) : emit("move", event, originalEvent),
onClone: (event) => emit("clone", event),
onChange: (event) => emit("change", event),
});

Related issue vuejs/core#8865

The reason is because emit() does not return the value from the handler.

Here are some proposals

  • Use props instead of emits
  • Respect the SortableOption instead of always overwriting them
  • Wait until Vue updates emit behavior, and mention that this functionality doesn't work
@nopeless
Copy link
Author

I am willing to submit a pr

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