Merge branch 'RED-7605' into 'master'

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

See merge request redactmanager/red-ui!119
This commit is contained in:
Dan Percic 2023-09-28 16:38:34 +02:00
commit 2c0033b8e1
2 changed files with 17 additions and 8 deletions

View File

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

View File

@ -108,14 +108,9 @@ export class PdfViewer {
}
deactivateSearch() {
this.#clearSearchResultsWhenVisibilityChanged();
this.#instance.UI.closeElements(['searchPanel']);
}
focusViewer() {
this.instance.UI.iframeWindow.focus();
}
resetAnnotationActions() {
if (this.#instance.UI.annotationPopup.getItems().length) {
this.#logger.info('[PDF] Reset annotation actions');
@ -167,8 +162,9 @@ export class PdfViewer {
this.#setSelectionMode();
this.#configureElements();
this.#disableHotkeys();
this.#clearSearchResultsWhenVisibilityChanged();
this.#listenForCommandF();
this.#listenForEsc();
this.#clearSearchResultsWhenVisibilityChanged();
});
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) {
if (this.isCompareMode()) {
if (page % 2 === 1) {
@ -351,4 +357,9 @@ export class PdfViewer {
input.select();
}
}
#focusViewer() {
this.instance.UI.iframeWindow.document.getElementById('SearchPanel__input').blur();
this.instance.UI.iframeWindow.focus();
}
}