From 2cbaa342d34c0bee63a43ba51c21896e134dae87 Mon Sep 17 00:00:00 2001 From: Anna Koskinen Date: Wed, 13 Oct 2021 17:13:17 +0300 Subject: [PATCH] Fix compatibility Grid column reorder of partially hidden joined cells. (#12427) Adds the fix from #12386 to the drag source as well. Fixes #12377 --- .../java/com/vaadin/v7/client/widgets/Grid.java | 7 +++++-- .../components/grid/GridReorderMergedTest.java | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java index efd50e3d1e..03556e3f79 100755 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java @@ -4485,8 +4485,11 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, @Override public void onDrop() { final int draggedColumnIndex = eventCell.getColumnIndex(); - final int colspan = header.getRow(eventCell.getRowIndex()) - .getCell(eventCell.getColumn()).getColspan(); + final StaticRow draggedCellRow = header + .getRow(eventCell.getRowIndex()); + Set> cellGroup = draggedCellRow + .getCellGroupForColumn(getColumn(draggedColumnIndex)); + final int colspan = cellGroup == null ? 1 : cellGroup.size(); if (latestColumnDropIndex != draggedColumnIndex && latestColumnDropIndex != draggedColumnIndex + colspan) { List> columns = getColumns(); diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridReorderMergedTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridReorderMergedTest.java index bab2ae2bb2..27f5e4711e 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridReorderMergedTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridReorderMergedTest.java @@ -24,4 +24,21 @@ public class GridReorderMergedTest extends MultiBrowserTest { assertEquals("Unexpected column order,", "6", grid.getHeaderCell(1, 1).getText()); } + + @Test + public void dragMergedReverse() { + openTestURL(); + GridElement grid = $(GridElement.class).first(); + GridCellElement headerCell0_0 = grid.getHeaderCell(0, 0); + GridCellElement headerCell0_4 = grid.getHeaderCell(0, 4); + new Actions(driver).clickAndHold(headerCell0_4) + .moveByOffset(-headerCell0_0.getSize().getWidth(), + headerCell0_0.getSize().getHeight() / 2) + .release().perform(); + + // ensure the second merged block got dragged over the first merged + // block entirely + assertEquals("Unexpected column order,", "6", + grid.getHeaderCell(1, 1).getText()); + } } -- 2.39.5