Required Information
Version(s) of Ext GWT
Ext GWT 3.0.1
Ext GWT 2.2.5 to current
Browser versions and OS (and desktop environment, if applicable)
I used the below environment but it isn't browser specific
  • Firefox 19, Windows 7
Virtual Machine
No
Description
All of the TreeDropTargets will not insert/append correctly when the user scrolls their browser window.
  • TreeGridDropTarget
  • TreeDropTarget
  • TreePanelDropTarget

Run mode
both

Steps to reproduce the problem
  1. Scroll your browser window down
  2. Try to drag and drop an item in a tree grid (using a treeDropTarget)

Expected result
You should be able to insert/append ...where you expect to be able to.
Actual result
You can't append/insert in a place where you would expect to be able to.
Test case
N/A

Helpful Information
Screenshot or video
  • «Link to attachment»
Live test «http://… Address for a test case for this bug on a running server»

Debugging already done
  • «none»
Possible fix
The issue is in the handleInsert method.

Code:
protected void handleInsert(DndDragMoveEvent event, final TreeNode<M> item) {
    int height = getWidget().getView().getRow(item.getModel()).getOffsetHeight();
    int mid = height / 2;
    int top = getWidget().getView().getRow(item.getModel()).getAbsoluteTop();
    mid += top;
    int y = event.getDragMoveEvent().getNativeEvent().getClientY();
    boolean before = y < mid;

    if ((!getWidget().isLeaf(item.getModel()) || allowDropOnLeaf)
        && (feedback == Feedback.BOTH || feedback == Feedback.APPEND)
        && ((before && y > top + 4) || (!before && y < top + height - 4))) {
      handleAppend(event, item);
      return;
    }
    //...
If you print out the values of top, mid, and y you will notice that y is relative to the browser while top is relative to the page.

In order to account for the window scroll you can simply add the following:

Code:
protected void handleInsert(DndDragMoveEvent event, final TreeNode<M> item) {
    int height = getWidget().getView().getRow(item.getModel()).getOffsetHeight();
    int mid = height / 2;
    int top = getWidget().getView().getRow(item.getModel()).getAbsoluteTop();
    // fix a bug in GXT whereas the window scroll isn't taken into account, which produces incorrect "top" values
    top -= Window.getScrollTop();
    mid += top;
    int y = event.getDragMoveEvent().getNativeEvent().getClientY();
    boolean before = y < mid;

    if ((!getWidget().isLeaf(item.getModel()) || allowDropOnLeaf)
        && (feedback == Feedback.BOTH || feedback == Feedback.APPEND)
        && ((before && y > top + 4) || (!before && y < top + height - 4))) {
      handleAppend(event, item);
      return;
    }
    //...