Browse Source

Catch and handle IllegalStateException (#11733)

* Catch and handle IllegalStateException

Fixes https://github.com/vaadin/framework/issues/11730

* Renaming variables
tags/8.9.1
Tatu Lund 4 years ago
parent
commit
0fa5bc69b2
1 changed files with 18 additions and 11 deletions
  1. 18
    11
      client/src/main/java/com/vaadin/client/widgets/Grid.java

+ 18
- 11
client/src/main/java/com/vaadin/client/widgets/Grid.java View File

return; return;
} }


Element e = Element.as(target);
RowContainer container = escalator.findRowContainer(e);
Element element = Element.as(target);
RowContainer container = escalator.findRowContainer(element);
Cell cell; Cell cell;


if (container == null) { if (container == null) {
} else { } else {
// Click might be in an editor cell, should still map. // Click might be in an editor cell, should still map.
if (editor.editorOverlay != null if (editor.editorOverlay != null
&& editor.editorOverlay.isOrHasChild(e)) {
&& editor.editorOverlay.isOrHasChild(element)) {
container = escalator.getBody(); container = escalator.getBody();
int rowIndex = editor.getRow(); int rowIndex = editor.getRow();
int colIndex = editor.getElementColumn(e);
int colIndex = editor.getElementColumn(element);


if (colIndex < 0) { if (colIndex < 0) {
// Click in editor, but not for any column. // Click in editor, but not for any column.
return; 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 { } else {
if (escalator.getElement().isOrHasChild(e)) {
if (escalator.getElement().isOrHasChild(element)) {
eventCell.set(new Cell(-1, -1, null), Section.BODY); eventCell.set(new Cell(-1, -1, null), Section.BODY);
// Fire native events. // Fire native events.
super.onBrowserEvent(event); super.onBrowserEvent(event);
} }
} }
} else { } else {
cell = container.getCell(e);
cell = container.getCell(element);
if (eventType.equals(BrowserEvents.MOUSEDOWN)) { if (eventType.equals(BrowserEvents.MOUSEDOWN)) {
cellOnPrevMouseDown = cell; cellOnPrevMouseDown = cell;
} else if (cell == null && eventType.equals(BrowserEvents.CLICK)) { } else if (cell == null && eventType.equals(BrowserEvents.CLICK)) {

Loading…
Cancel
Save