diff options
author | Tatu Lund <tatu@vaadin.com> | 2019-10-03 14:10:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-03 14:10:13 +0300 |
commit | 1b4409936d6437f7493303e6a0ebd25cd31985e0 (patch) | |
tree | cce6d2d271e779ca0f8692a2eaa84301c07251c8 /client/src | |
parent | 9381cf270132563f2ec7a05277211e0a64a16832 (diff) | |
download | vaadin-framework-1b4409936d6437f7493303e6a0ebd25cd31985e0.tar.gz vaadin-framework-1b4409936d6437f7493303e6a0ebd25cd31985e0.zip |
Catch and handle IllegalStateException (#11733)
* Catch and handle IllegalStateException
Fixes https://github.com/vaadin/framework/issues/11730
* Renaming variables
Diffstat (limited to 'client/src')
-rwxr-xr-x | client/src/main/java/com/vaadin/client/widgets/Grid.java | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/client/src/main/java/com/vaadin/client/widgets/Grid.java b/client/src/main/java/com/vaadin/client/widgets/Grid.java index 3a67dcfd3b..2cbeb9cd21 100755 --- a/client/src/main/java/com/vaadin/client/widgets/Grid.java +++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java @@ -7751,8 +7751,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, return; } - Element e = Element.as(target); - RowContainer container = escalator.findRowContainer(e); + Element element = Element.as(target); + RowContainer container = escalator.findRowContainer(element); Cell cell; if (container == null) { @@ -7764,23 +7764,30 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, } else { // Click might be in an editor cell, should still map. if (editor.editorOverlay != null - && editor.editorOverlay.isOrHasChild(e)) { + && editor.editorOverlay.isOrHasChild(element)) { container = escalator.getBody(); int rowIndex = editor.getRow(); - int colIndex = editor.getElementColumn(e); + int colIndex = editor.getElementColumn(element); if (colIndex < 0) { // Click in editor, but not for any column. return; } - TableCellElement cellElement = container - .getRowElement(rowIndex).getCells() - .getItem(colIndex); - - cell = new Cell(rowIndex, colIndex, cellElement); + try { + TableCellElement cellElement = container + .getRowElement(rowIndex).getCells() + .getItem(colIndex); + + cell = new Cell(rowIndex, colIndex, cellElement); + } catch (IllegalStateException exception) { + // IllegalStateException may occur if user has scrolled Grid so + // that Escalator has updated, and row under Editor is no longer + // there + return; + } } else { - if (escalator.getElement().isOrHasChild(e)) { + if (escalator.getElement().isOrHasChild(element)) { eventCell.set(new Cell(-1, -1, null), Section.BODY); // Fire native events. super.onBrowserEvent(event); @@ -7789,7 +7796,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, } } } else { - cell = container.getCell(e); + cell = container.getCell(element); if (eventType.equals(BrowserEvents.MOUSEDOWN)) { cellOnPrevMouseDown = cell; } else if (cell == null && eventType.equals(BrowserEvents.CLICK)) { |