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

fixed the console error while undoing a removed annotation
This commit is contained in:
Abhijith Sb 2025-11-05 20:41:26 +05:30 committed by GitHub
parent 74c92fa601
commit 2481208f31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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