From 44515e9f2319db0a339970ca1ecc36e09b4daa76 Mon Sep 17 00:00:00 2001 From: Nicoleta Panaghiu Date: Tue, 19 Sep 2023 12:11:57 +0300 Subject: [PATCH] RED-7605: Fixed ctrl+f and f not working properly. --- .../file-preview/file-preview-screen.component.ts | 7 +------ .../pdf-viewer/services/pdf-viewer.service.ts | 15 +++++++++++++-- .../src/app/modules/pdf-viewer/utils/constants.ts | 2 ++ libs/common-ui | 2 +- 4 files changed, 17 insertions(+), 9 deletions(-) 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 53169bc96..aed22cb1b 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 @@ -365,16 +365,11 @@ export class FilePreviewScreenComponent window.focus(); } - if (['f', 'F'].includes($event.key)) { + if (['f', 'F'].includes($event.key) && !$event.ctrlKey) { // if you type in an input, don't toggle full-screen if ($event.target instanceof HTMLInputElement || $event.target instanceof HTMLTextAreaElement) { return; } - if ($event.ctrlKey) { - this.pdf.focusSearch(); - this.pdf.activateSearch(); - return; - } this.toggleFullScreen(); return; 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 d85ec67cc..e7904083b 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 @@ -105,8 +105,10 @@ export class PdfViewer { focusSearch() { const iframeWindow = this.#instance.UI.iframeWindow; const input = iframeWindow.document.getElementById('SearchPanel__input') as HTMLInputElement; - input.focus(); - input.select(); + if (input) { + input.focus(); + input.select(); + } } activateSearch() { @@ -166,6 +168,7 @@ export class PdfViewer { this.#configureElements(); this.#disableHotkeys(); this.#clearSearchResultsWhenVisibilityChanged(); + this.#listenForCommandF(); return this.#instance; } @@ -275,6 +278,14 @@ export class PdfViewer { }); } + #listenForCommandF() { + this.#instance.UI.hotkeys.on('command+f, ctrl+f', e => { + e.preventDefault(); + this.activateSearch(); + this.focusSearch(); + }); + } + #navigateTo(pageNumber: number) { if (this.#currentInternalPage !== pageNumber) { this.documentViewer.displayPageLocation(pageNumber, 0, 0); diff --git a/apps/red-ui/src/app/modules/pdf-viewer/utils/constants.ts b/apps/red-ui/src/app/modules/pdf-viewer/utils/constants.ts index 51396e3c6..f6f552f57 100644 --- a/apps/red-ui/src/app/modules/pdf-viewer/utils/constants.ts +++ b/apps/red-ui/src/app/modules/pdf-viewer/utils/constants.ts @@ -68,6 +68,7 @@ export const DISABLED_HOTKEYS = [ 'CTRL+P', 'COMMAND+P', 'CTRL+F', + 'COMMAND+F', 'SPACE', 'UP', 'DOWN', @@ -77,6 +78,7 @@ export const DISABLED_HOTKEYS = [ 'C', 'E', 'I', + 'F', 'L', 'N', 'O', diff --git a/libs/common-ui b/libs/common-ui index 57375e248..ac3ccb1d7 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit 57375e24898d1fec8939f44e2f19a04eb3da08f7 +Subproject commit ac3ccb1d7dda79fa196269d3f0565bbcf5d9067d