aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorAnna Koskinen <Ansku@users.noreply.github.com>2021-06-30 11:53:18 +0300
committerGitHub <noreply@github.com>2021-06-30 11:53:18 +0300
commit347d36dcbccb07f1dd46f17ea5be6fceecc755cb (patch)
treea16bca23797f2d92cb3f06d4540c19a76fefa5bb /client
parentf70bc4269c264214f0ab8ac637df877ded55bddf (diff)
downloadvaadin-framework-347d36dcbccb07f1dd46f17ea5be6fceecc755cb.tar.gz
vaadin-framework-347d36dcbccb07f1dd46f17ea5be6fceecc755cb.zip
Ensure removing a row does not cause exceptions in detail row handling. (#12330)
Fixes: #12328
Diffstat (limited to 'client')
-rw-r--r--client/src/main/java/com/vaadin/client/connectors/grid/DetailsManagerConnector.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/client/src/main/java/com/vaadin/client/connectors/grid/DetailsManagerConnector.java b/client/src/main/java/com/vaadin/client/connectors/grid/DetailsManagerConnector.java
index 5290effdfa..b419aef724 100644
--- a/client/src/main/java/com/vaadin/client/connectors/grid/DetailsManagerConnector.java
+++ b/client/src/main/java/com/vaadin/client/connectors/grid/DetailsManagerConnector.java
@@ -17,6 +17,7 @@ package com.vaadin.client.connectors.grid;
import java.util.HashMap;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.TreeMap;
import com.google.gwt.core.client.Scheduler;
@@ -680,6 +681,18 @@ public class DetailsManagerConnector extends AbstractExtensionConnector {
getWidget().setDetailsVisible(rowIndex, false);
}
+ private void detachDetailsIfFound(String connectorId) {
+ if (indexToDetailConnectorId.containsValue(connectorId)) {
+ for (Entry<Integer, String> entry : indexToDetailConnectorId
+ .entrySet()) {
+ if (connectorId.equals(entry.getValue())) {
+ detachDetails(entry.getKey());
+ return;
+ }
+ }
+ }
+ }
+
private boolean refreshDetails(int rowIndex) {
String id = getDetailsComponentConnectorId(rowIndex);
String oldId = indexToDetailConnectorId.get(rowIndex);
@@ -706,6 +719,11 @@ public class DetailsManagerConnector extends AbstractExtensionConnector {
indexToDetailConnectorId.remove(rowIndex);
} else {
// updated, replace reference
+
+ // ensure that the detail contents aren't still attached to some
+ // other row that hasn't been refreshed yet
+ detachDetailsIfFound(id);
+
indexToDetailConnectorId.put(rowIndex, id);
newOrUpdatedDetails = true;
getWidget().resetVisibleDetails(rowIndex);
@@ -714,6 +732,11 @@ public class DetailsManagerConnector extends AbstractExtensionConnector {
// new Details content, listeners will get attached to the connector
// when Escalator requests for the Details through
// CustomDetailsGenerator#getDetails(int)
+
+ // ensure that the detail contents aren't still attached to some
+ // other row that hasn't been refreshed yet
+ detachDetailsIfFound(id);
+
indexToDetailConnectorId.put(rowIndex, id);
newOrUpdatedDetails = true;
getWidget().setDetailsVisible(rowIndex, true);