@@ -6,13 +6,13 @@ import { useQueryClient, type QueryClient } from '@tanstack/react-query';
66import { isEmpty } from 'lodash-es' ;
77import type { DatasetItem } from 'src/constants/shared-types' ;
88import { useAnnotationActions } from 'src/shared/annotator/annotation-actions-provider.component' ;
9+ import { useAnnotator } from 'src/shared/annotator/annotator-provider.component' ;
910
1011import { DeleteMediaItem } from '../../gallery/delete-media-item/delete-media-item.component' ;
1112import { LabelPicker } from './label-picker.component' ;
1213import { useSecondaryToolbarState } from './use-secondary-toolbar-state.hook' ;
1314
1415import classes from '../media-preview.module.scss' ;
15- import { useAnnotator } from 'src/shared/annotator/annotator-provider.component' ;
1616
1717type SecondaryToolbarProps = {
1818 items : DatasetItem [ ] ;
@@ -35,7 +35,7 @@ export const SecondaryToolbar = ({ items, mediaItem, onClose, onSelectedMediaIte
3535 const queryClient = useQueryClient ( ) ;
3636 const { annotations, isSaving, submitAnnotations } = useAnnotationActions ( ) ;
3737 const { selectedLabel, setSelectedLabelId } = useAnnotator ( ) ;
38- const { isHidden, projectLabels } = useSecondaryToolbarState ( ) ;
38+ const { isHidden, projectLabels, addLabels } = useSecondaryToolbarState ( ) ;
3939
4040 const hasAnnotations = ! isEmpty ( annotations ) ;
4141 const selectedIndex = items . findIndex ( ( item ) => item . id === mediaItem . id ) ;
@@ -69,7 +69,15 @@ export const SecondaryToolbar = ({ items, mediaItem, onClose, onSelectedMediaIte
6969 < LabelPicker
7070 selectedLabel = { selectedLabel }
7171 labels = { projectLabels }
72- onSelect = { ( value ) => setSelectedLabelId ( value !== null ? String ( value ) : null ) }
72+ onSelect = { ( value ) => {
73+ const labelId = value !== null ? String ( value ) : null ;
74+
75+ setSelectedLabelId ( labelId ) ;
76+
77+ if ( labelId && ! isHidden ) {
78+ addLabels ( labelId ) ;
79+ }
80+ } }
7381 />
7482
7583 < ButtonGroup >
0 commit comments