Skip to content

Commit 261e267

Browse files
authored
Use onNewView instead of MutationObserver in zoomed in plot (#4218)
1 parent 1b08e1b commit 261e267

File tree

2 files changed

+2
-37
lines changed

2 files changed

+2
-37
lines changed

webview/src/plots/components/ZoomedInPlot.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import cloneDeep from 'lodash.clonedeep'
66
import { reverseOfLegendSuppressionUpdate } from 'dvc/src/plots/vega/util'
77
import styles from './styles.module.scss'
88
import { getThemeValue, ThemeProperty } from '../../util/styles'
9-
import { useMutationObserver } from '../hooks/useMutationObserver'
109
import { exportPlotData } from '../util/messages'
1110

1211
type ZoomedInPlotProps = {
@@ -29,14 +28,8 @@ export const ZoomedInPlot: React.FC<ZoomedInPlotProps> = ({
2928
}
3029
}, [])
3130

32-
const onPlotChange = () => {
31+
const onNewView = () => {
3332
const actions = zoomedInPlotRef.current?.querySelector('.vega-actions')
34-
const createdRawDataAction = actions?.querySelector(
35-
`.${styles.vegaCustomAction as string}`
36-
)
37-
if (createdRawDataAction) {
38-
return
39-
}
4033
const rawDataAction = document.createElement('a')
4134
rawDataAction.textContent = 'Save Raw Data'
4235
rawDataAction.addEventListener('click', () => {
@@ -46,8 +39,6 @@ export const ZoomedInPlot: React.FC<ZoomedInPlotProps> = ({
4639
actions?.append(rawDataAction)
4740
}
4841

49-
useMutationObserver(zoomedInPlotRef, onPlotChange)
50-
5142
return (
5243
<div
5344
className={styles.zoomedInPlot}
@@ -66,6 +57,7 @@ export const ZoomedInPlot: React.FC<ZoomedInPlotProps> = ({
6657
export: true,
6758
source: false
6859
}}
60+
onNewView={onNewView}
6961
/>
7062
</div>
7163
)

webview/src/plots/hooks/useMutationObserver.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)