From aba95b9980db419a8ad436ac6ac0dbd049c570f2 Mon Sep 17 00:00:00 2001 From: Andrea Papaleo Date: Thu, 27 Jun 2024 12:22:28 -0400 Subject: [PATCH] [mod,fix] passes default category kind if no selected category --- .../useAnnotationState/useAnnotationState.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/hooks/useAnnotationState/useAnnotationState.ts b/src/hooks/useAnnotationState/useAnnotationState.ts index 5e2c518f..b327713f 100644 --- a/src/hooks/useAnnotationState/useAnnotationState.ts +++ b/src/hooks/useAnnotationState/useAnnotationState.ts @@ -39,14 +39,8 @@ export const useAnnotationState = (annotationTool: AnnotationTool) => { const onAnnotated = useMemo(() => { const func = () => { - dispatch( - annotatorSlice.actions.setAnnotationState({ - annotationState: AnnotationState.Annotated, - kind: selectedCategory?.kind, - annotationTool, - }) - ); if (selectionMode !== AnnotationMode.New) return; + if (!selectedCategory) { if (!defaultSelectedCategory) return; dispatch( @@ -66,6 +60,14 @@ export const useAnnotationState = (annotationTool: AnnotationTool) => { activeImageId! ); } + + dispatch( + annotatorSlice.actions.setAnnotationState({ + annotationState: AnnotationState.Annotated, + kind: selectedCategory?.kind ?? defaultSelectedCategory?.kind, + annotationTool, + }) + ); }; return func; }, [