From 5de011c09da4ffea350eb0a67d0d126cee067817 Mon Sep 17 00:00:00 2001 From: Nicoleta Panaghiu Date: Thu, 28 Nov 2024 16:23:01 +0200 Subject: [PATCH] RED-10563: fixed pdf search input. --- .../pdf-viewer/services/pdf-viewer.service.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/apps/red-ui/src/app/modules/pdf-viewer/services/pdf-viewer.service.ts b/apps/red-ui/src/app/modules/pdf-viewer/services/pdf-viewer.service.ts index 09f1fe58e..9a1ad929b 100644 --- a/apps/red-ui/src/app/modules/pdf-viewer/services/pdf-viewer.service.ts +++ b/apps/red-ui/src/app/modules/pdf-viewer/services/pdf-viewer.service.ts @@ -114,6 +114,11 @@ export class PdfViewer { return page$.pipe(map(page => this.#adjustPage(page))); } + get #searchInput() { + const iframeWindow = this.#instance.UI.iframeWindow; + return iframeWindow.document.getElementById('SearchPanel__input') as HTMLInputElement; + } + activateSearch() { this.#instance.UI.searchTextFull('', this.searchOptions); } @@ -290,13 +295,13 @@ export class PdfViewer { #listenForShift() { this.#instance.UI.iframeWindow.addEventListener('keydown', e => { - e.preventDefault(); + if (e.target === this.#searchInput) return; if (e.key === 'Shift') { this.#setSelectionMode(SelectionModes.RECTANGULAR); } }); this.#instance.UI.iframeWindow.addEventListener('keyup', e => { - e.preventDefault(); + if (e.target === this.#searchInput) return; if (e.key === 'Shift') { this.#setSelectionMode(SelectionModes.STRUCTURAL); } @@ -389,13 +394,11 @@ export class PdfViewer { if (this.#isElementActive('textPopup')) { this.#instance.UI.closeElements(['textPopup']); } - const iframeWindow = this.#instance.UI.iframeWindow; - const input = iframeWindow.document.getElementById('SearchPanel__input') as HTMLInputElement; - if (input) { - input.focus(); + if (this.#searchInput) { + this.#searchInput.focus(); } - if (input?.value?.length > 0) { - input.select(); + if (this.#searchInput?.value?.length > 0) { + this.#searchInput.select(); } }