Popup anchor location not properly set when dragging to create events

On my EventCalendar implementation (timeline mode, day or week) I have enabled dragToCreate and clickToCreate. I also have a Popup component that appears when an event is created or clicked on. When I click an event (onEventClicked handler), I am setting the anchor to args.domEvent.target which properly positions the popup. The target element in this case is .mbsc-schedule-event-range.

On drag to create, I want the popup to appear in the same position as if I had clicked on the new event, but I am unable to properly set the anchor to .mbsc-schedule-event-range like in onEventClicked. In onEventCreated the value of args.domEvent.target is a drag target element that takes up the entirety of the calendar, so the popup is not positioned properly. My current workaround is to set the popup anchor in onEventDragStart, but it’s far from ideal, as the popup will be positioned underneath wherever I started dragging, rather than centered beneath the new event.

Any ideas of how to properly position my popup in this scenario?

Hi @Alec1

Thanks for reaching out!

As I see you’re trying to access the created event element through the args.domEvent.target property however the onEventCreated event’s args parameter has a separate target property which directly contains the DOM element of the created event.
I’ve checked and the args.target value contains the correct DOM element so you should be able to use that.

Thanks @szili1,

Looks like I had been using the onEventCreate instead of onEventCreated. I switched to onEventCreated and am getting the anchor set properly now with args.target. Thanks for your help!