Cancel drag & drop on the onEventDragEnd event

Hi,
After dragging an event, on the onEventDragEnd method, I have a custom check if it’s possible to drag the event to the target time or not.
(I have to check it on live dragging because it’s for specific objects with specific properties that can be changed)
If my custom check says it’s not possible so I need to have the ability to cancel the drag&drop and to go back to where it was or to have the previous event with the old time so I can manually do it.
how can that be achieved?

Hi Hadas!
You should use the onEventUpdate method. You have access to oldEvent and event (the actual, modified event) objects. If based on your criteria you do not want to update to the “new” event, just return false and the specified event will jump back to it’s original position. I hope it helps :wink:

1 Like

Hi,
Thank you! it was exactly what I needed…
I have somehow related question reg adding an event,
I have a “extendDefaultEvent” method that is adding properties to the new event, as far as I understood it’s not really adding the event on this part, but only on the “onEventCreated”, and I want to add the event also based on a criteria, so on the “extendDefaultEvent” I have the condition - and if it’s ok than it return the event object with the new properties, otherwise I see it returns the default new event object that is build in… but what happens is that it shows the new event like you can see in the screenshot I attached, and it is only disappears after refreshing the page, so how can I prevent the event from adding the default event to the dom?

this is my extendDefaultEvent -
const myDefaultEvent= useCallback((args) => {
const shift = findClosestShift(args.resource, args.start);
if (shift != undefined) {
return {
start: shift.start,
end: shift.end,
shiftId: shift.id,
resource: args.resource
};
}
},
[findClosestShift]
);

image