Mouse click Drop outside scale error


When changing duration with drag & drop and the drop is outside the scale the “mouse click event” behaves very strange.
The task bars length is following the mouse cursor until I reload the entire page.

It is especially a problem when the task duration is 0 and you are trying to change the duration with drag & drop.

Is there some way to avoid this?

Gantt is listening for task drag mouse event in chart. If you move mouse outside chart it doesn’t handle mouse events. If mouseup was fired outside chart and bar follows mouse you can just click on chart and DND will be finished (without page reloading).
It is default internal behaivour and there is no correct way to change it. You could try to redefine gantt._tasks_dnd.set_actions to attach event listeners not to chart but to document.body for example. Or you could ty to add mouse up handler to window and finish dnd with calling on_mouse_up. For example:

gantt.event(window, "mouseup", function(e) {
            if (gantt.getState().drag_id && !gantt.$task_data.contains(

Thank you so much, your example works perfect :slight_smile: