diff --git a/src/plugins/graph/adornments/movable-line/movable-line-model.ts b/src/plugins/graph/adornments/movable-line/movable-line-model.ts index 65f919d93d..9279264a7a 100644 --- a/src/plugins/graph/adornments/movable-line/movable-line-model.ts +++ b/src/plugins/graph/adornments/movable-line/movable-line-model.ts @@ -121,9 +121,11 @@ export const MovableLineModel = AdornmentModel .views(self => ({ getAnnotatableObjects(tileId: string) { const objects: IClueObject[] = []; - for (const key of self.lines.keys()) { - objects.push({ tileId, objectType: "movable-line-handle", objectId: getAnnotationId(key, "lower") }); - objects.push({ tileId, objectType: "movable-line-handle", objectId: getAnnotationId(key, "upper") }); + if (self.isVisible) { + for (const key of self.lines.keys()) { + objects.push({ tileId, objectType: "movable-line-handle", objectId: getAnnotationId(key, "lower") }); + objects.push({ tileId, objectType: "movable-line-handle", objectId: getAnnotationId(key, "upper") }); + } } return objects; } diff --git a/src/plugins/graph/adornments/movable-line/movable-line.tsx b/src/plugins/graph/adornments/movable-line/movable-line.tsx index 2479e980f5..5ead1e7897 100644 --- a/src/plugins/graph/adornments/movable-line/movable-line.tsx +++ b/src/plugins/graph/adornments/movable-line/movable-line.tsx @@ -135,7 +135,11 @@ export const MovableLine = observer(function MovableLine(props: IProps) { .attr('cx', x) .attr('cy', y); const annotationId = getAnnotationId(instanceKey, index===1 ? "lower" : "upper"); - annotationLocationSetter?.set(annotationId, { x, y }); + if (model.isVisible) { + annotationLocationSetter?.set(annotationId, { x, y }); + } else { + annotationLocationSetter?.set(annotationId, undefined); + } } } @@ -387,6 +391,7 @@ export const MovableLine = observer(function MovableLine(props: IProps) { newLineObject.equation = equationDiv; setLineObject(newLineObject); + // disposer return () => { equationDiv.remove(); }; diff --git a/src/plugins/graph/graph-types.ts b/src/plugins/graph/graph-types.ts index 346fb663f8..384875f601 100644 --- a/src/plugins/graph/graph-types.ts +++ b/src/plugins/graph/graph-types.ts @@ -113,7 +113,7 @@ export const GraphEditModes = ["none", "edit", "add"]; export type GraphEditMode = typeof GraphEditModes[number]; export interface ILocationSetterContext { - set: (id: string, location: Point) => void; + set: (id: string, location: Point|undefined) => void; } export const LocationSetterContext = createContext(undefined); diff --git a/src/plugins/graph/models/graph-model.ts b/src/plugins/graph/models/graph-model.ts index 1f5ab88797..74079977ac 100644 --- a/src/plugins/graph/models/graph-model.ts +++ b/src/plugins/graph/models/graph-model.ts @@ -414,8 +414,12 @@ export const GraphModel = TileContentModel setInteractionInProgress(value: boolean) { self.interactionInProgress = value; }, - setAnnotationLocation(id: string, location: Point) { - self.annotationLocationCache.set(id, location); + setAnnotationLocation(id: string, location: Point|undefined) { + if (location) { + self.annotationLocationCache.set(id, location); + } else { + self.annotationLocationCache.delete(id); + } } })) .actions(self => ({