Skip to content

Commit

Permalink
fix: do not trigger data communicator reset when no filters (#6712)
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen authored Oct 11, 2024
1 parent 98c9d5d commit 45ff63f
Showing 1 changed file with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1448,8 +1448,10 @@ public UpdateQueueData getUpdateQueueData() {

private SerializableFunction<T, String> classNameGenerator = item -> null;
private SerializableFunction<T, String> partNameGenerator = item -> null;
private SerializablePredicate<T> dropFilter = item -> true;
private SerializablePredicate<T> dragFilter = item -> true;
private SerializablePredicate<T> defaultDropFilter = item -> true;
private SerializablePredicate<T> defaultDragFilter = item -> true;
private SerializablePredicate<T> dropFilter = defaultDropFilter;
private SerializablePredicate<T> dragFilter = defaultDragFilter;
private Map<String, SerializableFunction<T, String>> dragDataGenerators = new HashMap<>();

private Registration dataProviderChangeRegistration;
Expand Down Expand Up @@ -4566,7 +4568,15 @@ public Registration addDragEndListener(
public void setDropMode(GridDropMode dropMode) {
getElement().setProperty("dropMode",
dropMode == null ? null : dropMode.getClientName());
getDataCommunicator().reset();

// Do not reset the data communicator if no filters are applied in order
// to avoid unnecessary scroll position reset. This can be removed when
// Flow will provide a way to request refresh for only items that
// are in the viewport.
if (dragFilter != defaultDragFilter
|| dropFilter != defaultDropFilter) {
getDataCommunicator().reset();
}
}

/**
Expand All @@ -4591,7 +4601,15 @@ public GridDropMode getDropMode() {
*/
public void setRowsDraggable(boolean rowsDraggable) {
getElement().setProperty("rowsDraggable", rowsDraggable);
getDataCommunicator().reset();

// Do not reset the data communicator if no filters are applied in order
// to avoid unnecessary scroll position reset. This can be removed when
// Flow will provide a way to request refresh for only items that
// are in the viewport.
if (dragFilter != defaultDragFilter
|| dropFilter != defaultDropFilter) {
getDataCommunicator().reset();
}
}

/**
Expand Down

0 comments on commit 45ff63f

Please sign in to comment.