Issue with Simultaneously Enabling "auto_scheduling " and "drag_project "

When both "auto_scheduling " and “drag_project” are enabled simultaneously, dragging a task of type “project” causes an issue where it cannot be dragged to the left after the second drag.

https://snippet.dhtmlx.com/evo0yaf6

Dragging a “Construction Phase” task triggers the mentioned problem, while dragging a “Foundation” task behaves as expected.

Hello,
Thank you for reporting the bug. It is related to the constraint dates. When you drag a task, Gantt adds the SNET constraint so the task is not moved to an earlier date after you auto-schedule it:
https://docs.dhtmlx.com/gantt/desktop__auto_scheduling.html#timeconstraintsfortasks

When you drag project tasks, you are actually dragging all child tasks, and Gantt adds the SNET constraint to each child task. After you drag the project the second time, the child tasks already have the constraint dates, so they are not moved to an earlier date because of the constraint rule.
I investigated the use case, and it seems that if the task ID has a number value that is smaller than the project ID, the project task is dragged correctly. But if the child ID has a greater value than the parent’s task ID, it is iterated later, so, the constraint is applied after the child task is auto-scheduled to the previous constraint date:
https://snippet.dhtmlx.com/3wlxe6jy

However, we are aware of the issue. Regardless of how it works with the task IDs, it is related to the fact that the constraint dates of the child tasks are not updated correctly. The bug should be fixed in the future, but I cannot give you any ETA.

As a workaround, you can remove the constraint date for all children when dragging a project task:

gantt.attachEvent("onTaskDrag", function(id, mode, task, original){
  if (task.type == gantt.config.types.project){
    gantt.eachTask(function(child){
      child.constraint_date = null;
    },task.id)
  }
});

Here is the snippet:
https://snippet.dhtmlx.com/fmi34qjs

1 Like

Hello,
The dev team fixed the bug when it wasn’t possible to drag a project task if its children are linked:
https://docs.dhtmlx.com/gantt/whatsnew.html#:~:text=The%20onAfterTaskUpdate%20event%20now%20fires%20before%20Auto%20Scheduling%20events%20after%20dragging%20tasks%20in%20the%20timeline

You can see that the bug is no longer reproduced in the following sample:
http://snippet.dhtmlx.com/5/7dd3d9b5c