Unable to close the context menu on Gantt scroll


We are unable to “remove the context menu” when we are scrolling the Gantt and we were able to reproduce the issue using DHX code snippet tool as well.

We have added horizontal and vertical scrollbars in both grid area and timeline area and context menu will be displayed if you right click on a task.

We have called a method to remove context menu on “onTaskClick”, “onEmptyClick” and “onGanttScroll” events. However, once context menu is open and if we scroll the grid area or the timeline area (both horizontally and vertically), context menu is not getting closed (we have noticed that “onGanttScroll” is not getting fired).

Snippet is available at: https://snippet.dhtmlx.com/c8vqq5nv

Could you please help us to resolve this issue.

Thank you.


The onGanttScroll handler listens to the scrolling only of the required views with their IDs:
https://docs.dhtmlx.com/gantt/desktop__layout_config.html#requiredviewsandsettings ;
So it means that you need to specify the required IDs of the scrollbars to the certain view:

{view: "scrollbar", id: "scrollHor"},
{view: "scrollbar", id: "scrollVer"}

But when each view has its own scrollbars in the custom layout, Gantt only tracks scroll changes in views that use the above scrollbars IDs.
As a workaround, you can use Gantt’s internal events to track scrollbar changes in the certain layout view. So you can get the required layout view by using the gantt.$ui.getView method and attach the onScroll event:
It might look like:

gantt.attachEvent("onGanttReady", function () {
    gantt.$ui.getView("grid").attachEvent("onScroll", function (pos) {

Please check the example of how it might be implemented:

1 Like