From 3bdbb1e4c62122b7b039bde0e85a5d4fd7969031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Mon, 28 Mar 2022 19:10:58 +0300 Subject: [PATCH] RED-3603, RED-3710: arrow navigation, again --- .../components/pdf-viewer/pdf-viewer.component.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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); }