Fix : Problems related to measurement operation undo (#5541)

fixed the console error while undoing a removed annotation
This commit is contained in:
Abhijith Sb authored and GitHub committed 2025-11-05 10:11:26 -05:00
1 parent 74c92fa601
commit 2481208f31
1 file changed
+9 -5
@@ -503,11 +503,15 @@ const connectMeasurementServiceToTools = ({
}
const removedAnnotation = annotation.state.getAnnotation(removedMeasurementId);
removeAnnotation(removedMeasurementId);
commandsManager.run('triggerCreateAnnotationMemo', {
annotation: removedAnnotation,
FrameOfReferenceUID: removedAnnotation.metadata.FrameOfReferenceUID,
options: { deleting: true },
});
// Ensure `removedAnnotation` is available before triggering the memo,
// as it can be undefined during an undo operation
if (removedAnnotation) {
commandsManager.run('triggerCreateAnnotationMemo', {
annotation: removedAnnotation,
FrameOfReferenceUID: removedAnnotation.metadata.FrameOfReferenceUID,
options: { deleting: true },
});
}
const renderingEngine = cornerstoneViewportService.getRenderingEngine();
// Note: We could do a better job by triggering the render on the
// viewport itself, but the removeAnnotation does not include that info...