Skip to content

Commit

Permalink
fix: disable reordering when the grid is sorted
Browse files Browse the repository at this point in the history
  • Loading branch information
javier-godoy authored and paodb committed Jan 28, 2022
1 parent 549a7b0 commit da2e630
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ ListDataProvider<T> getDataProvider() {
Collection<T> getItems() {
return getDataProvider().getItems();
}

boolean isReorderingEnabled() {
return allowReordering && grid.getSortOrder().isEmpty();
}
}

/** enumeration of all available orientation for TwinGolGrid component */
Expand Down Expand Up @@ -750,8 +754,10 @@ private void configDragAndDrop(
draggedItems.addAll(event.getDraggedItems());
}

sourceModel.grid.setDropMode(sourceModel.allowReordering ? GridDropMode.BETWEEN : null);
targetModel.grid.setDropMode(targetModel.allowReordering ? GridDropMode.BETWEEN : GridDropMode.ON_GRID);
sourceModel.grid
.setDropMode(sourceModel.isReorderingEnabled() ? GridDropMode.BETWEEN : null);
targetModel.grid.setDropMode(
targetModel.isReorderingEnabled() ? GridDropMode.BETWEEN : GridDropMode.ON_GRID);
});

sourceModel.grid.addDragEndListener(
Expand Down Expand Up @@ -787,7 +793,7 @@ private void configDragAndDrop(

sourceModel.grid.addDropListener(event -> {
event.getDropTargetItem().ifPresent(dropOverItem -> {
if (sourceModel.allowReordering
if (sourceModel.isReorderingEnabled()
&& event.getSource() == draggedGrid
&& !draggedItems.contains(dropOverItem)
&& !draggedItems.isEmpty()) {
Expand Down

0 comments on commit da2e630

Please sign in to comment.