onSelectEvent / onDeSelectEvent needed

Is it possible to get an event fired when a single event is selected/deselected? The onSelectedEventsChange doesn’t fire unless selectMultipleEvents is enabled, and onEventClick doesn’t help as I can’t get an event when it’s deselected. Not sure why onSelectedEventsChange wouldn’t be implemented even with selectMultipleEvents = false as it seems like an arbitrary limitation.

I could try to handle this with onSelectedEventsChange but I don’t want multiple events to be selectable. All other solutions seem hacky.

Hi @MichaelBrown :wave:

That’s right, at the moment the onSelectedEventsChange is only triggered when the selectMultipleEvents is enabled.

Besides that, can you share more information about the use case? - I’m curious about the context.

Sure. My use case has two purposes to using single event selection.

I have an appointment calendar that allows the user to make multiple edits and save all of their changes at once. This involves selecting single events and making modifications to them (edits or delete of the event via keyboard).

If selectMultipleEvents is false, I can use the onEventClick handler to detect when an event is selected (and the class .mbsc-schedule-event-active is applied showing it’s been selected) - however there is no event fired for when it is unselected.

Also I am using single click of an event to open a sidebar (anchored to edge of page) and close the sidebar when the event is unselected. A double click on the event opens the event details. I could use onEventClick to tell when it’s selected but again there is no event for when event focus is lost.

I can solve this temporarily by setting selectMultipleEvents={true} which enables the onSelectedEventsChange event, however this enables shift-click selection and that’s not valid in my scenario. It would be most ideal to have an event selected/deselected that fires even if selectMultipleEvents is false (much like any windows UI control would do). It doesn’t make a lot of sense to only fire that event for multiple selection, or perhaps implement a onSelectedEventChange for single event selection mode.

Here’s a sample of the UI:

event_selection

Thanks for sharing :wink:

Actually, at the moment I can’t find any easier solution for this than using the selectMultipleEvents={true} from which you can get those events, as you mentioned.