[APM] Don't trigger map layout if no elements (#66625)

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.
This commit is contained in:
Nathan L Smith 2020-05-14 16:30:40 -05:00 committed by GitHub
parent e6ef168181
commit a54de76e1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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.