SchedulerEditItem unexpectedly triggers onRelease instead of onClick

2 Answers 65 Views
Scheduler
Grant
Top achievements
Rank 3
Iron
Iron
Veteran
Grant asked on 27 Sep 2023, 09:01 AM

Hi team, 

I've created a `CustomScheulerEditItem` component to handle use cases when the user double clicks and item and when then move it.

However I've noticed that when clicking or double clicking an item, the `SchedulerEditItem` triggers the `onRelease` callback and then the `onClick` or `onDoubleClick`.  Due to this behaviour, the action I need to complete onClick, never happens.

I have an example here in stackblitz (https://stackblitz.com/edit/react-nc1tnr?file=app%2Fmain.jsx), now I know that the `onClick` callback is working, but its being preceded by `onRelease`. Have I impl this incorrectly? please advise how I can ignore the `onRelease` when simply clicking on the Item.

Thanks,
Grant

2 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 28 Sep 2023, 09:44 AM

Hello Grant,

Thank you for contacting us.

The onRelease event is part of the Drag&Drop functionality and it passes information about the drag event. Having both the onRelease and onClick event handlers should not interfere with the logic that you want to execute within the onClick event. 

Note that the onRelease will have SchedulerItemDragEvent as parameters and the onClick will have SchedulerItemMouseEvent. I have to say that the SchedulerItem has many events and some of them can actually overlap (for example onRelease, onMouseUp, onClick, etc.). 

In regards of your question for preventing the onRelease, if you want to execute some logic within the onRelease event, I would assume that you can still keep it and also keep the logic for the onClick event. However, if you are facing issues with this combination, please share a stackblitz example demonstrating the exact problem that you are facing, so we can test it locally and see if we can suggest a solution for it.

 

Regards,
Konstantin Dikov
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources!

0
Grant
Top achievements
Rank 3
Iron
Iron
Veteran
answered on 29 Sep 2023, 08:17 AM

Morning Konstantin, 

Thanks for getting back to me, I've updated the sandbox top better demo my issue, see here.

My requirements call for a customized Occurrence Dialog to determine if you are viewing (resizing/moving) a series or an occurrence.

In my demo, when you dblclick the event, the onRelease is triggered first, which opens a window (with a modal) that asks if you want to move the event.
Since the modal is is under the window, the event doesnt register the second click, and the onDoubleClick never gets triggered.

I've noticed that if I change the double click to a single click, the bug doesnt occur.

If you remove the modal from the window and double click, you can see the onRelase triggers and opens the window asking about moving,
then the 2nd click registers and you can see the window change its title from 'move' to 'view'. This isnt the desired behaviour though.

I hope I've been able to articulate the bug so its understandable.

Thanks,
Grant

 

Konstantin Dikov
Telerik team
commented on 03 Oct 2023, 07:49 AM

Hi Grant,

I checked the scenario and what I could suggest is to check if there is a dragItem within the onRelease event (e.target.props.dragItem). If there is no item, this would indicate that no dragging have occurred:

const onReleaseHandler = React.useCallback(
    (e) => {
      console.log('onReleaseHandler');
      if (e.target.props.dragItem) {
        setOccurrenceAction('Move Event');
      }

      if (onRelease) {
        onRelease(e);
      }
    },
    [onRelease]
  );

Please let me know if this works for your scenario.

 

Grant
Top achievements
Rank 3
Iron
Iron
Veteran
commented on 04 Oct 2023, 11:17 AM

Thanks Konstantin, resolved.
Tags
Scheduler
Asked by
Grant
Top achievements
Rank 3
Iron
Iron
Veteran
Answers by
Konstantin Dikov
Telerik team
Grant
Top achievements
Rank 3
Iron
Iron
Veteran
Share this question
or