Skip to content

Commit

Permalink
fix: ignore non-column children when setting column order (#6733)
Browse files Browse the repository at this point in the history
  • Loading branch information
sissbruecker authored Oct 21, 2024
1 parent 994acec commit e01de0c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ private void reorderColumnsAndConsumeIDs(Component column,

// holds the current immediate child columns.
final Set<AbstractColumn<?>> childColumns = new HashSet<>();
column.getChildren().filter(c -> !(c instanceof GridSelectionColumn))
.forEach(it -> childColumns.add((AbstractColumn) it));
column.getChildren().filter(c -> c instanceof AbstractColumn<?>)
.forEach(it -> childColumns.add((AbstractColumn<?>) it));
// the new order of the children is computed here.
final List<AbstractColumn<?>> newOrder = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.junit.Test;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.Label;
import com.vaadin.flow.data.renderer.IconRenderer;

Expand Down Expand Up @@ -314,6 +315,16 @@ public void setColumnOrder_joinedHeader3() {
secondColumn, thirdColumn }, grid.getColumns().toArray());
}

@Test
public void setColumnOrder_ignoresNonColumnChildren() {
grid.setEmptyStateComponent(new Div());

grid.setColumnOrder(fourthColumn, thirdColumn, secondColumn,
firstColumn);
assertArrayEquals(new Object[] { fourthColumn, thirdColumn,
secondColumn, firstColumn }, grid.getColumns().toArray());
}

private String dumpColumnHierarchyFromDOM() {
return dumpColumnHierarchyFromDOM(grid);
}
Expand Down

0 comments on commit e01de0c

Please sign in to comment.