diff options
author | Henrik Paul <henrik@vaadin.com> | 2014-10-16 15:54:56 +0300 |
---|---|---|
committer | Henrik Paul <henrik@vaadin.com> | 2014-10-24 13:09:16 +0300 |
commit | c430aa77c2fee0742cfd8c5e6df5397933dba9b8 (patch) | |
tree | a756329f545f60f4bf39eed148d9990c2f039f2f | |
parent | 43c43cfe883edf776657a787332d43aa9482f6bb (diff) | |
download | vaadin-framework-c430aa77c2fee0742cfd8c5e6df5397933dba9b8.tar.gz vaadin-framework-c430aa77c2fee0742cfd8c5e6df5397933dba9b8.zip |
Fixes exception when dragging on cells in Chrome (#13334)
Change-Id: I67b16e15884d9d44d99fcd1fa8063559babcb856
-rw-r--r-- | client/src/com/vaadin/client/ui/grid/Grid.java | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/client/src/com/vaadin/client/ui/grid/Grid.java b/client/src/com/vaadin/client/ui/grid/Grid.java index 38590507aa..dcb34fd8cc 100644 --- a/client/src/com/vaadin/client/ui/grid/Grid.java +++ b/client/src/com/vaadin/client/ui/grid/Grid.java @@ -771,6 +771,22 @@ public class Grid<T> extends ResizeComposite implements private boolean dataIsBeingFetched = false; /** + * The cell a click event originated from + * <p> + * This is a workaround to make Chrome work like Firefox. In Chrome, + * normally if you start a drag on one cell and release on: + * <ul> + * <li>that same cell, the click event is that {@code <td>}. + * <li>a cell on that same row, the click event is the parent {@code <tr>}. + * <li>a cell on another row, the click event is the table section ancestor + * ({@code <thead>}, {@code <tbody>} or {@code <tfoot>}). + * </ul> + * + * @see #onBrowserEvent(Event) + */ + private Cell cellOnPrevMouseDown; + + /** * Enumeration for easy setting of selection mode. */ public enum SelectionMode { @@ -2282,15 +2298,32 @@ public class Grid<T> extends ResizeComposite implements RowContainer container = escalator.findRowContainer(e); Cell cell; boolean isGrid = Util.findWidget(e, null) == this; + if (container == null) { // TODO: Add a check to catch mouse click outside of table but // inside of grid cell = activeCellHandler.getActiveCell(); container = activeCellHandler.container; - } else { + } + + else { cell = container.getCell(e); + if (event.getType().equals(BrowserEvents.MOUSEDOWN)) { + cellOnPrevMouseDown = cell; + } else if (cell == null + && event.getType().equals(BrowserEvents.CLICK)) { + /* + * Chrome has an interesting idea on click targets (see + * cellOnPrevMouseDown javadoc). Firefox, on the other hand, has + * the mousedown target as the click target. + */ + cell = cellOnPrevMouseDown; + } } + assert cell != null : "received " + event.getType() + + "-event with a null cell target"; + // Editor Row can steal focus from Grid and is still handled if (handleEditorRowEvent(event, container, cell)) { return; |