From 8405496a7a6f6808fe829485c677bb73b4fa670c Mon Sep 17 00:00:00 2001 From: Artur Date: Mon, 30 Jan 2017 15:19:55 +0200 Subject: [PATCH] Prevent reorder of frozen columns when there are hidden columns (#8278) * Rename variables to indicate whether they use DOM index or Grid index Grid indexes include hidden columns, DOM/Escalator indexes do not * Prevent reorder of frozen columns when there are hidden columns Fixes #8265 * Merge branch '7.7' into _grid-no-reorder-of-frozen-columns * Merge branch '7.7' into _grid-no-reorder-of-frozen-columns * Merge branch '7.7' into _grid-no-reorder-of-frozen-columns * Merge branch '7.7' into _grid-no-reorder-of-frozen-columns * Merge branch '7.7' into _grid-no-reorder-of-frozen-columns * Merge branch '7.7' into _grid-no-reorder-of-frozen-columns * Merge branch '7.7' into _grid-no-reorder-of-frozen-columns --- .../java/com/vaadin/client/widgets/Grid.java | 3 +-- .../server/GridColumnReorderTest.java | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 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 d215b3c565..7ef2167f1c 100755 --- a/client/src/main/java/com/vaadin/client/widgets/Grid.java +++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java @@ -7602,8 +7602,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, if (!event.getCell().isHeader()) { return; } - if (event.getCell().getColumnIndex() < escalator - .getColumnConfiguration().getFrozenColumnCount()) { + if (event.getCell().getColumnIndex() < getFrozenColumnCount()) { return; } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnReorderTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnReorderTest.java index c6d6f44a00..6e83c2503f 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnReorderTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnReorderTest.java @@ -208,6 +208,29 @@ public class GridColumnReorderTest extends GridBasicFeaturesTest { assertFalse(getGridElement().getHeaderCell(0, 2).isFrozen()); } + @Test + public void testColumnReorder_draggingFrozenColumnsContainingHiddenColumns_impossible() { + // given + openTestURL(); + selectMenuPath("Component", "Size", "Width", "900px"); + toggleColumnReordering(); + setFrozenColumns(4); + toggleColumnHidden(1); + toggleColumnHidden(2); + assertColumnHeaderOrder(0, 3, 4, 5); + + // when + // drag frozen column out between non-frozen columns + dragAndDropDefaultColumnHeader(1, 2, CellSide.RIGHT); + + // then + // everything should be as before + assertColumnHeaderOrder(0, 3, 4, 5); + assertTrue(getGridElement().getHeaderCell(0, 0).isFrozen()); + assertTrue(getGridElement().getHeaderCell(0, 1).isFrozen()); + assertFalse(getGridElement().getHeaderCell(0, 2).isFrozen()); + } + @Test public void testColumnReorder_draggingColumnOnTopOfFrozenColumn_columnDroppedRightOfFrozenColumns() { // given -- 2.39.5