Skip to content

Commit be9c41b

Browse files
committed
[APM] Disable map layout animation (#66763)
* [APM] Disable map layout animation Don't animate the layout. Keep animation for centering/zoom. `preventDefault` when centering an already focused node so it doesn't do an unnecessary navigation. Fixes #66695
1 parent 5627897 commit be9c41b

3 files changed

Lines changed: 19 additions & 15 deletions

File tree

x-pack/plugins/apm/public/components/app/ServiceMap/Cytoscape.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ function getLayoutOptions(
8181
fit: true,
8282
padding: nodeHeight,
8383
spacingFactor: 0.85,
84-
animate: true,
85-
animationEasing: animationOptions.easing,
86-
animationDuration: animationOptions.duration,
8784
// @ts-ignore
8885
// Rotate nodes counter-clockwise to transform layout from top→bottom to left→right.
8986
// The extra 5° achieves the effect of separating overlapping taxi-styled edges.

x-pack/plugins/apm/public/components/app/ServiceMap/Popover/Contents.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
import theme from '@elastic/eui/dist/eui_theme_light.json';
1616
import { i18n } from '@kbn/i18n';
1717
import cytoscape from 'cytoscape';
18-
import React from 'react';
18+
import React, { MouseEvent } from 'react';
1919
import styled from 'styled-components';
2020
import { fontSize, px } from '../../../../style/variables';
2121
import { Buttons } from './Buttons';
@@ -31,7 +31,7 @@ const popoverMinWidth = 280;
3131
interface ContentsProps {
3232
isService: boolean;
3333
label: string;
34-
onFocusClick: () => void;
34+
onFocusClick: (event: MouseEvent<HTMLAnchorElement>) => void;
3535
selectedNodeData: cytoscape.NodeDataDefinition;
3636
selectedNodeServiceName: string;
3737
}

x-pack/plugins/apm/public/components/app/ServiceMap/Popover/index.tsx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { EuiPopover } from '@elastic/eui';
88
import cytoscape from 'cytoscape';
99
import React, {
1010
CSSProperties,
11+
MouseEvent,
1112
useCallback,
1213
useContext,
1314
useEffect,
@@ -16,8 +17,8 @@ import React, {
1617
} from 'react';
1718
import { SERVICE_NAME } from '../../../../../common/elasticsearch_fieldnames';
1819
import { CytoscapeContext } from '../Cytoscape';
19-
import { Contents } from './Contents';
2020
import { animationOptions } from '../cytoscapeOptions';
21+
import { Contents } from './Contents';
2122

2223
interface PopoverProps {
2324
focusedServiceName?: string;
@@ -87,14 +88,18 @@ export function Popover({ focusedServiceName }: PopoverProps) {
8788
}
8889
}, [popoverRef, x, y]);
8990

90-
const centerSelectedNode = useCallback(() => {
91-
if (cy) {
92-
cy.animate({
93-
...animationOptions,
94-
center: { eles: cy.getElementById(selectedNodeServiceName) }
95-
});
96-
}
97-
}, [cy, selectedNodeServiceName]);
91+
const centerSelectedNode = useCallback(
92+
(event: MouseEvent<HTMLAnchorElement>) => {
93+
event.preventDefault();
94+
if (cy) {
95+
cy.animate({
96+
...animationOptions,
97+
center: { eles: cy.getElementById(selectedNodeServiceName) }
98+
});
99+
}
100+
},
101+
[cy, selectedNodeServiceName]
102+
);
98103

99104
const isAlreadyFocused = focusedServiceName === selectedNodeServiceName;
100105

@@ -110,7 +115,9 @@ export function Popover({ focusedServiceName }: PopoverProps) {
110115
<Contents
111116
isService={isService}
112117
label={label}
113-
onFocusClick={isAlreadyFocused ? centerSelectedNode : deselect}
118+
onFocusClick={
119+
isAlreadyFocused ? centerSelectedNode : _event => deselect()
120+
}
114121
selectedNodeData={selectedNodeData}
115122
selectedNodeServiceName={selectedNodeServiceName}
116123
/>

0 commit comments

Comments
 (0)