diff --git a/apps/red-ui/src/app/modules/file-preview/components/pdf-viewer/pdf-viewer.component.ts b/apps/red-ui/src/app/modules/file-preview/components/pdf-viewer/pdf-viewer.component.ts index 065f88ee5..388bc218f 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/pdf-viewer/pdf-viewer.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/pdf-viewer/pdf-viewer.component.ts @@ -194,9 +194,20 @@ export class PdfViewerComponent extends AutoUnsubscribe implements OnInit, OnCha await this._configureTextPopup(); this.annotationManager.addEventListener('annotationSelected', async (annotations: Annotation[], action) => { - const nextAnnotations = this.multiSelectService.isEnabled ? this.annotationManager.getSelectedAnnotations() : annotations; + let nextAnnotations: Annotation[]; + + if (action === 'deselected') { + // Remove deselected annotations from selected list + nextAnnotations = this.annotationManager.getSelectedAnnotations().filter(ann => !annotations.find(a => a.Id === ann.Id)); + } else if (!this.multiSelectService.isEnabled) { + // Only choose the last selected annotation, to bypass viewer multi select + nextAnnotations = annotations; + } else { + // Get selected annotations from the manager, no intervention needed + nextAnnotations = this.annotationManager.getSelectedAnnotations(); + } + this.annotationSelected.emit(nextAnnotations.map(ann => ann.Id)); - this.annotationSelected.emit(action === 'selected' ? nextAnnotations.map(ann => ann.Id) : []); if (action === 'deselected') { return this._toggleRectangleAnnotationAction(true); }