-
28 Feb 2013 10:09 AM #1
Bug with Tree[...]DropTarget
Bug with Tree[...]DropTarget
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
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- Scroll your browser window down
- 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»
Debugging already done- «none»
The issue is in the handleInsert method.
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.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; } //...
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; } //...
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote