From 886f253fa15ef2f95a9dfc2033256725b7bc5660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Thu, 11 Mar 2021 00:00:42 +0200 Subject: [PATCH] Clear search results on search panel close --- .../screens/file/pdf-viewer/pdf-viewer.component.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/red-ui/src/app/screens/file/pdf-viewer/pdf-viewer.component.ts b/apps/red-ui/src/app/screens/file/pdf-viewer/pdf-viewer.component.ts index 382623e6f..1e23aa9ee 100644 --- a/apps/red-ui/src/app/screens/file/pdf-viewer/pdf-viewer.component.ts +++ b/apps/red-ui/src/app/screens/file/pdf-viewer/pdf-viewer.component.ts @@ -150,6 +150,18 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { } }); + instance.iframeWindow.addEventListener('visibilityChanged', (event: any) => { + if (event.detail.element === 'searchPanel') { + const inputElement = instance.iframeWindow.document.getElementById('SearchPanel__input') as HTMLInputElement; + setTimeout(() => { + inputElement.value = ''; + }, 0); + if (!event.detail.isVisible) { + instance.docViewer.clearSearchResults(); + } + } + }); + this._loadDocument(); }); }