]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix compatibility Grid column reorder of partially hidden joined cells. (#12427)
authorAnna Koskinen <Ansku@users.noreply.github.com>
Wed, 13 Oct 2021 14:13:17 +0000 (17:13 +0300)
committerGitHub <noreply@github.com>
Wed, 13 Oct 2021 14:13:17 +0000 (17:13 +0300)
Adds the fix from #12386 to the drag source as well.

Fixes #12377

compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java
uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridReorderMergedTest.java

index efd50e3d1e6f43a6862a33f34e3c2823d838240e..03556e3f7906faaf1b3ec86b48d2dc1b3ed85152 100755 (executable)
@@ -4485,8 +4485,11 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
         @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<Column<?, ?>> cellGroup = draggedCellRow
+                    .getCellGroupForColumn(getColumn(draggedColumnIndex));
+            final int colspan = cellGroup == null ? 1 : cellGroup.size();
             if (latestColumnDropIndex != draggedColumnIndex
                     && latestColumnDropIndex != draggedColumnIndex + colspan) {
                 List<Column<?, T>> columns = getColumns();
index bab2ae2bb2c56f14d2ccf5673c8b862c2f4df5ac..27f5e4711eb04529b96dffb0c5c75c5a6bdc4d00 100644 (file)
@@ -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());
+    }
 }