From 4e3e64f2eb3bb16bab94ab94dab1f220cb090d7d Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Wed, 16 Oct 2024 23:07:56 +0300 Subject: [PATCH] RED-9944 - cancel the bulk-selection mode when a user clicks somewhere else --- .../file-workload/file-workload.component.ts | 12 ++++++++++++ .../file-preview/file-preview-screen.component.ts | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts b/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts index 788204e00..ec3b87e49 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts @@ -588,4 +588,16 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On this.displayedPages.every((value, index) => value === newDisplayedPages[index]) ); } + + @HostListener('click', ['$event']) + clickInsideWorkloadView($event: MouseEvent) { + $event?.stopPropagation(); + } + + @HostListener('document: click') + clickOutsideWorkloadView() { + if (this.multiSelectService.active()) { + this.multiSelectService.deactivate(); + } + } } diff --git a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts index 512f783bd..b3c28bfaf 100644 --- a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts @@ -253,6 +253,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni ngOnDestroy() { this.pdf.instance.UI.hotkeys.off('esc'); + this.pdf.instance.UI.iframeWindow.document.removeEventListener('click', this.handleViewerClick); super.ngOnDestroy(); } @@ -277,6 +278,15 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni } } + @Bind() + handleViewerClick() { + this._ngZone.run(() => { + if (this._multiSelectService.active()) { + this._multiSelectService.deactivate(); + } + }); + } + async ngOnAttach(previousRoute: ActivatedRouteSnapshot) { if (!this.state.file().canBeOpened) { return this.#navigateToDossier(); @@ -307,6 +317,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni this.#restoreOldFilters(); this.pdf.instance.UI.hotkeys.on('esc', this.handleEscInsideViewer); this._viewerHeaderService.resetLayers(); + this.pdf.instance.UI.iframeWindow.document.addEventListener('click', this.handleViewerClick); } async openRectangleAnnotationDialog(manualRedactionEntryWrapper: ManualRedactionEntryWrapper) {