RED-7605: Fixed ctrl+f and f not working properly.

This commit is contained in:
Nicoleta Panaghiu 2023-09-19 12:11:57 +03:00
parent 7336cafeac
commit 44515e9f23
4 changed files with 17 additions and 9 deletions

View File

@ -365,16 +365,11 @@ export class FilePreviewScreenComponent
window.focus(); 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 you type in an input, don't toggle full-screen
if ($event.target instanceof HTMLInputElement || $event.target instanceof HTMLTextAreaElement) { if ($event.target instanceof HTMLInputElement || $event.target instanceof HTMLTextAreaElement) {
return; return;
} }
if ($event.ctrlKey) {
this.pdf.focusSearch();
this.pdf.activateSearch();
return;
}
this.toggleFullScreen(); this.toggleFullScreen();
return; return;

View File

@ -105,8 +105,10 @@ export class PdfViewer {
focusSearch() { focusSearch() {
const iframeWindow = this.#instance.UI.iframeWindow; const iframeWindow = this.#instance.UI.iframeWindow;
const input = iframeWindow.document.getElementById('SearchPanel__input') as HTMLInputElement; const input = iframeWindow.document.getElementById('SearchPanel__input') as HTMLInputElement;
input.focus(); if (input) {
input.select(); input.focus();
input.select();
}
} }
activateSearch() { activateSearch() {
@ -166,6 +168,7 @@ export class PdfViewer {
this.#configureElements(); this.#configureElements();
this.#disableHotkeys(); this.#disableHotkeys();
this.#clearSearchResultsWhenVisibilityChanged(); this.#clearSearchResultsWhenVisibilityChanged();
this.#listenForCommandF();
return this.#instance; 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) { #navigateTo(pageNumber: number) {
if (this.#currentInternalPage !== pageNumber) { if (this.#currentInternalPage !== pageNumber) {
this.documentViewer.displayPageLocation(pageNumber, 0, 0); this.documentViewer.displayPageLocation(pageNumber, 0, 0);

View File

@ -68,6 +68,7 @@ export const DISABLED_HOTKEYS = [
'CTRL+P', 'CTRL+P',
'COMMAND+P', 'COMMAND+P',
'CTRL+F', 'CTRL+F',
'COMMAND+F',
'SPACE', 'SPACE',
'UP', 'UP',
'DOWN', 'DOWN',
@ -77,6 +78,7 @@ export const DISABLED_HOTKEYS = [
'C', 'C',
'E', 'E',
'I', 'I',
'F',
'L', 'L',
'N', 'N',
'O', 'O',

@ -1 +1 @@
Subproject commit 57375e24898d1fec8939f44e2f19a04eb3da08f7 Subproject commit ac3ccb1d7dda79fa196269d3f0565bbcf5d9067d