Updating an existing event by dragging

When I use the drag handle at the beginning or end of an existing event, the scheduler makes a new event (i.e. fires the OnEventCreate event). How can I prevent the creation of a new object. All of the events on the calendar are recurring events if this helps?
I would think if I am modifying an existing event it wouldn’t fire the OnEventCreate?
I have dragToCreate={true}

Hello @Jason :wave:

Based on the described usage, I’m assuming you only activated the dragToCreate option but, that’s for creating new events. - and that’s why the onEventCreate fires and creates a new event.

If you want to allow the event resize, you should use the dragToResize option.

What if I want both options, I want to drag to create in the first instance, then, I want to modify the created event, so I use the dragToResize to do this, but the dragToCreate is creating a new object? How has this not come up as a problem before, if the event is created already, and I am dragging an existing items drag handle, then why would dragToCreate fire at all???

Sorry forgot to mention, dragToResize is already set to true. I am using the scheduler view BTW.

<Eventcalendar
theme=“material”
themeVariant=“light”
clickToCreate={true}
dragToCreate={true}
dragToMove={true}
dragToResize={true}
eventDelete={true}
groupBy=“date”
//colors={colors}
data={userHours.hours}
view={view}
onEventClick={onEventClick}
onEventCreate={onEventCreate}
onEventDelete={onEventDelete}
onEventCreateFailed={onEventCreateFailed}
onEventUpdateFailed={onEventUpdateFailed}
invalid={locationClosedHours}
renderDay={renderDay}
showControls={false}
extendDefaultEvent={extendDefaultEvent}
/>

Regarding your requirement: sure, you can use the two options together without any problem, please see this example which demonstrates exactly what you need - https://demo.mobiscroll.com/react/scheduler/move-resize-drag-drop-to-create-events - as you can see, here it works as expected.

OK but try the onEventCreateEvent, wire this up and see if this fires when you drag to resize an event, if it does, surely this should not fire?? We are not creating we are resizing (updating). Also remember all my events a recurring events, I checked the originEvent and this was never part of the event object in the MbscEventCreateEvent object

As I mentioned in my previous answer, the dragToResize option will allow the events to be resize-able.

Also in the object I pasted earlier, you can see that DragToResize is set to true

You can check the fired events in this demo: https://demo.mobiscroll.com/react/scheduler/event-hooks# - you can see, that when you resize an event, the onEventCreate doesn’t fire.

Are these flags set on that demo???

clickToCreate={true}
dragToCreate={true}
dragToMove={true}
dragToResize={true}

Yup :point_down:
Example

And are the events recurring events?

They are not and sorry for the misunderstanding :slight_smile: - yesterday I didn’t notice that you were talking about recurring events.

In this case, the scenario is as you described, by default, if a recurring event is modified (resized, etc.) the original event will be updated with a recurring exception for the modified instance. This will produce an onEventUpdate event. Furthermore, for the modified instance another event is created, because this event will be different from the recurring event. So the onEventCreate is also fired for that event.

You can check this, if you further modify a modified recurring event instance, then you will only have the onEventUpdate fired, since that instance is no longer part of the recurring set.

I hope this explains :wink:

Besides that, I’m curious about why would you like to prevent this behavior? - so, feel free to share more information about the context/ use case.