From 803e0f3df80e225fb03874922ba6a2585d38bcef Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Tue, 13 Oct 2020 22:17:34 -0500 Subject: [PATCH] Set new data on elements after fetch. (#80430) When `add`ing an element with an already existing ID, it will use the already existing data instead of setting new data. This made it so when you change the time picker the element health statuses would not update. When we get new elements, replace the existing data for existing elements. Fixes #80335. --- .../apm/public/components/app/ServiceMap/Cytoscape.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/x-pack/plugins/apm/public/components/app/ServiceMap/Cytoscape.tsx b/x-pack/plugins/apm/public/components/app/ServiceMap/Cytoscape.tsx index d65ce1879ce02..7b944ed1b6ceb 100644 --- a/x-pack/plugins/apm/public/components/app/ServiceMap/Cytoscape.tsx +++ b/x-pack/plugins/apm/public/components/app/ServiceMap/Cytoscape.tsx @@ -84,6 +84,11 @@ function CytoscapeComponent({ cy.elements().forEach((element) => { if (!elementIds.includes(element.data('id'))) { cy.remove(element); + } else { + // Doing an "add" with an element with the same id will keep the original + // element. Set the data with the new element data. + const newElement = elements.find((el) => el.data.id === element.id()); + element.data(newElement?.data ?? element.data()); } }); cy.trigger('custom:data', [fit]);