diff options
author | Tatu Lund <tatu@vaadin.com> | 2020-09-04 13:35:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-04 13:35:13 +0300 |
commit | 58bcc95f15a0c7bf032daabd885ba76984a789ee (patch) | |
tree | 1148b8229b9845120197c1f82a0f1d8d0c751624 /client/src | |
parent | 63434f9939968c9c7629b03b39016575dcf813c4 (diff) | |
download | vaadin-framework-58bcc95f15a0c7bf032daabd885ba76984a789ee.tar.gz vaadin-framework-58bcc95f15a0c7bf032daabd885ba76984a789ee.zip |
Fix IndexOutOfBoundsException when adding columns in Grid (#12095)
There is regression in Vaadin 7.7.16 and later, which is due patch https://github.com/vaadin/framework/commit/eafd44672650e076fc4a43362e11b47ffb0dbff1 that can lead to IndexOutOfBoundsException when there is hidden columns while adding new columns, which is similiar issue than earlier reported in https://github.com/vaadin/framework/issues/6784. Essentially the performance improvement patch overwrite some of the fix logic of https://github.com/vaadin/framework/commit/84533057435a99b0d0dfa9ea791de81921c1e260 This fix bring overwriten escalator index compensation back.
Diffstat (limited to 'client/src')
-rwxr-xr-x | client/src/main/java/com/vaadin/client/widgets/Grid.java | 8 |
1 files changed, 7 insertions, 1 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 7ef61eff5b..5be104fe50 100755 --- a/client/src/main/java/com/vaadin/client/widgets/Grid.java +++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java @@ -6540,8 +6540,14 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, } } if (visibleNewColumns > 0) { + int escalatorIndex = index; + for (int existingColumn = 0; existingColumn < index; existingColumn++) { + if (getColumn(existingColumn).isHidden()) { + escalatorIndex--; + } + } final ColumnConfiguration columnConfiguration = this.escalator.getColumnConfiguration(); - columnConfiguration.insertColumns(index, visibleNewColumns); + columnConfiguration.insertColumns(escalatorIndex, visibleNewColumns); } for (final Column<?, T> column : columnCollection) { |