From 6a7437cc96da860e50297e064abe7aef387c9e2c Mon Sep 17 00:00:00 2001 From: Henrik Paul Date: Tue, 24 Mar 2015 15:11:23 +0200 Subject: Fixes edge case in null details generation for Grid (#17274) Change-Id: I1bf4c2f0600baea8b925bd31dcd42c1e901a7c8b --- .../vaadin/client/connectors/GridConnector.java | 28 +++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'client') diff --git a/client/src/com/vaadin/client/connectors/GridConnector.java b/client/src/com/vaadin/client/connectors/GridConnector.java index 7c568e02e5..51e986933c 100644 --- a/client/src/com/vaadin/client/connectors/GridConnector.java +++ b/client/src/com/vaadin/client/connectors/GridConnector.java @@ -19,6 +19,7 @@ package com.vaadin.client.connectors; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -677,8 +678,13 @@ public class GridConnector extends AbstractHasComponentsConnector implements customDetailsGenerator .setDetailsConnectorChanges(connectorChanges); + List removedFirst = new ArrayList( + connectorChanges); + Collections.sort(removedFirst, + DetailsConnectorChange.REMOVED_FIRST_COMPARATOR); + // refresh moved/added details rows - for (DetailsConnectorChange change : connectorChanges) { + for (DetailsConnectorChange change : removedFirst) { Integer oldIndex = change.getOldIndex(); Integer newIndex = change.getNewIndex(); @@ -689,13 +695,23 @@ public class GridConnector extends AbstractHasComponentsConnector implements + "invalid new index: " + newIndex + " (connector: " + change.getConnector() + ")"; - Integer index = newIndex; - if (index == null) { - index = oldIndex; + if (oldIndex != null) { + /* Close the old/removed index */ + getWidget().setDetailsVisible(oldIndex, false); + + if (change.isShouldStillBeVisible()) { + getWidget().setDetailsVisible(oldIndex, true); + } } - getWidget().setDetailsVisible(index, false); - getWidget().setDetailsVisible(index, true); + if (newIndex != null) { + /* + * Since the component was lazy loaded, we need to + * refresh the details by toggling it. + */ + getWidget().setDetailsVisible(newIndex, false); + getWidget().setDetailsVisible(newIndex, true); + } } detailsConnectorFetcher.responseReceived(fetchId); } -- cgit v1.2.3