-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(events): ANNOTATION_REMOVED event listener on removing ALL annotations. #1236
Conversation
✅ Deploy Preview for cornerstone-3d-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
if (annotationToRemove !== null) { | ||
triggerEvent(eventTarget, csToolEvents.ANNOTATION_REMOVED, { | ||
annotation: annotationToRemove, | ||
annotationManagerUID: this.uid, | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you examine other sections in this file, we don't publish events here but rather in the annotationState
. Could you perhaps follow the same pattern?
@@ -223,16 +217,6 @@ function removeAnnotation(annotationUID: string): void { | |||
); | |||
|
|||
manager.removeAnnotation(annotationUID); | |||
|
|||
// trigger annotation removed | |||
const eventType = Events.ANNOTATION_REMOVED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think make a copy here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my comments please
*/ | ||
function removeAnnotations(groupKey: string, toolName?: string): void { | ||
const manager = getAnnotationManager(); | ||
const removedAnnotations = manager.removeAnnotations(groupKey, toolName); | ||
|
||
for (const annotation of removedAnnotations) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't expect this, why groupKey is part of the params? can you follow how other state functions behave please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it is meant to be AnnotationGroupSelector instead of string? I will make this change as that is how other functions in this file handle this.
I made that function parameter more in-line with the other functions in that file. Thank you for these reviews. |
…/ChandlerClevenger/main
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I just re-orderd the params to be consistent with other annotation state APIs
Context
Fixes #1056
Changes & Results
Moved code from FrameOfReferenceSpecificAnnotationManager into annotationState and re-used the same annotation removal code.
Testing
I used the annotationVisibility example and added another button to remove selected annotation OR if none are selected it would remove them all. I tested this way and it worked.
Checklist
PR
semantic-release format and guidelines.
Code
My code has been well-documented (function documentation, inline comments,
etc.)
I have run the
yarn build:update-api
to update the API documentation, and havecommitted the changes to this PR. (Read more here https://www.cornerstonejs.org/docs/contribute/update-api)
N/A really
Public Documentation Updates
additions or removals.
Tested Environment