knockout-sortablejs icon indicating copy to clipboard operation
knockout-sortablejs copied to clipboard

onMove return value not passed back to Sortablejs

Open crystalfp opened this issue 4 years ago • 0 comments
trafficstars

I define a onMove function to prevent list sorting this way:

onMove(event) {
    console.log("onMove called");
    return false;
}

and pass it to knockout-sortablejs:

            <div data-bind="sortable: {foreach: documentList, options: {
                            onMove: $component.onMove,
                            handle: '.list-layout-handle'}}">

When I move an element, the onMove function is called, but the return value that should prevent sorting is ignored.

The solution seems to be adding a missing return to lines 79 and 81 this way:

                    if (handler)
                        return handler(e, itemVM, parentVM, collection, bindings);
                    if (eventHandlers[eventType])
                        return eventHandlers[eventType](e, itemVM, parentVM, collection, bindings);

Hope it can help mario

crystalfp avatar Feb 14 '21 06:02 crystalfp