RED-7605: Fixed search again + esc only on document focused.

This commit is contained in:
Nicoleta Panaghiu 2023-09-28 17:36:29 +03:00
parent 6478111524
commit 127ce75789
2 changed files with 17 additions and 8 deletions

View File

@ -397,8 +397,6 @@ export class FilePreviewScreenComponent
$event.preventDefault(); $event.preventDefault();
this.fullScreen = false; this.fullScreen = false;
this.closeFullScreen(); this.closeFullScreen();
this.pdf.deactivateSearch();
this.pdf.focusViewer();
this._changeRef.markForCheck(); this._changeRef.markForCheck();
} }

View File

@ -108,14 +108,9 @@ export class PdfViewer {
} }
deactivateSearch() { deactivateSearch() {
this.#clearSearchResultsWhenVisibilityChanged();
this.#instance.UI.closeElements(['searchPanel']); this.#instance.UI.closeElements(['searchPanel']);
} }
focusViewer() {
this.instance.UI.iframeWindow.focus();
}
resetAnnotationActions() { resetAnnotationActions() {
if (this.#instance.UI.annotationPopup.getItems().length) { if (this.#instance.UI.annotationPopup.getItems().length) {
this.#logger.info('[PDF] Reset annotation actions'); this.#logger.info('[PDF] Reset annotation actions');
@ -167,8 +162,9 @@ export class PdfViewer {
this.#setSelectionMode(); this.#setSelectionMode();
this.#configureElements(); this.#configureElements();
this.#disableHotkeys(); this.#disableHotkeys();
this.#clearSearchResultsWhenVisibilityChanged();
this.#listenForCommandF(); this.#listenForCommandF();
this.#listenForEsc();
this.#clearSearchResultsWhenVisibilityChanged();
}); });
return this.#instance; return this.#instance;
@ -267,6 +263,16 @@ export class PdfViewer {
}); });
} }
#listenForEsc() {
this.#instance.UI.hotkeys.on('esc', e => {
e.preventDefault();
if (this.#isElementActive('searchPanel')) {
this.deactivateSearch();
this.#focusViewer();
}
});
}
#adjustPage(page: number) { #adjustPage(page: number) {
if (this.isCompareMode()) { if (this.isCompareMode()) {
if (page % 2 === 1) { if (page % 2 === 1) {
@ -351,4 +357,9 @@ export class PdfViewer {
input.select(); input.select();
} }
} }
#focusViewer() {
this.instance.UI.iframeWindow.document.getElementById('SearchPanel__input').blur();
this.instance.UI.iframeWindow.focus();
}
} }