]> source.dussan.org Git - vaadin-framework.git/commitdiff
Catch exception that is thrown when Grid is scrolled during operation (#12002) pr12027/r6
authorTatu Lund <tatu@vaadin.com>
Thu, 14 May 2020 12:02:58 +0000 (15:02 +0300)
committerGitHub <noreply@github.com>
Thu, 14 May 2020 12:02:58 +0000 (15:02 +0300)
IllegalStateException may occur if user has scrolled Grid (compatibility library version) so that Escalator has updated, and row under Editor is no longer there

Chrerry pick from https://github.com/vaadin/framework/pull/11467

compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java

index 1d2f88f57062ccad627671504a3fe57505cd5913..4a7265a5250df98aa16b581e6547fa381b4b5fc2 100755 (executable)
@@ -2145,13 +2145,19 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
 
             // sometimes focus handling twists the editor row out of alignment
             // with the grid itself and the position needs to be compensated for
-            TableRowElement rowElement = grid.getEscalator().getBody()
-                .getRowElement(grid.getEditor().getRow());
-            int rowLeft = rowElement.getAbsoluteLeft();
-            int editorLeft = cellWrapper.getAbsoluteLeft();
-            if (editorLeft != rowLeft + frozenWidth) {
-                cellWrapper.getStyle().setLeft(newLeft + rowLeft - editorLeft,
-                    Unit.PX);
+            try {
+                TableRowElement rowElement = grid.getEscalator().getBody()
+                    .getRowElement(grid.getEditor().getRow());
+                int rowLeft = rowElement.getAbsoluteLeft();
+                int editorLeft = cellWrapper.getAbsoluteLeft();
+                if (editorLeft != rowLeft + frozenWidth) {
+                    cellWrapper.getStyle().setLeft(newLeft + rowLeft - editorLeft,
+                        Unit.PX);
+                }
+            } catch (IllegalStateException e) {
+                // IllegalStateException may occur if user has scrolled Grid so
+                // that Escalator has updated, and row under Editor is no longer
+                // there
             }
         }