From 3f6811e4d63295f79d65eee77f3247a336da34c8 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Thu, 14 May 2020 22:01:14 -0500 Subject: [PATCH] [APM] Don't trigger map layout if no elements (#66625) (#66653) After simplyfying the layout mechanism in #66438, we made it so the `data` event handler would run even if there are no elements. This causes the `layoutstop` handler to run as well, but if we have multiple renders with no elements, multiple `layoutstop` events would by triggered after the elements were loaded, causing the map to jump around, which is especially visible with a single node. Fixes #66528. --- .../plugins/apm/public/components/app/ServiceMap/Cytoscape.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 2633771c8b031..5d1ca923cbc8f 100644 --- a/x-pack/plugins/apm/public/components/app/ServiceMap/Cytoscape.tsx +++ b/x-pack/plugins/apm/public/components/app/ServiceMap/Cytoscape.tsx @@ -146,7 +146,7 @@ export function Cytoscape({ }; const dataHandler: cytoscape.EventHandler = event => { - if (cy) { + if (cy && cy.elements().length > 0) { if (serviceName) { resetConnectedEdgeStyle(cy.getElementById(serviceName)); // Add the "primary" class to the node if its id matches the serviceName.