RED-7296: remove event listener.

This commit is contained in:
Nicoleta Panaghiu 2024-02-06 14:24:49 +02:00
parent 44bda08834
commit 75ce020cb5

View File

@ -181,8 +181,6 @@ export class FilePreviewScreenComponent
}
}
});
this.#handleDeleteRectangleOnEsc();
}
get changed() {
@ -296,11 +294,13 @@ export class FilePreviewScreenComponent
this._viewerHeaderService.enableLoadAllAnnotations(); // Reset the button state (since the viewer is reused between files)
super.ngOnDetach();
document.documentElement.removeEventListener('fullscreenchange', this.fullscreenListener);
this.pdf.instance.UI.hotkeys.off('esc');
this._changeRef.markForCheck();
}
ngOnDestroy() {
document.documentElement.removeEventListener('fullscreenchange', this.fullscreenListener);
this.pdf.instance.UI.hotkeys.off('esc');
super.ngOnDestroy();
}
@ -343,6 +343,7 @@ export class FilePreviewScreenComponent
this.pdfProxyService.configureElements();
this.#restoreOldFilters();
document.documentElement.addEventListener('fullscreenchange', this.fullscreenListener);
this.pdf.instance.UI.hotkeys.on('esc', this.#handleDeleteRectangle);
this.#openComponentLogDialogIfDefault();
this._viewerHeaderService.resetLayers();
@ -588,18 +589,16 @@ export class FilePreviewScreenComponent
return newAnnotations;
}
#handleDeleteRectangleOnEsc() {
this.pdf.instance.UI.hotkeys.on('esc', e => {
e.preventDefault();
if (!!this._annotationManager.selected[0]) {
const doesHaveWrapper = this._fileDataService.find(this._annotationManager.selected[0]?.Id);
if (!doesHaveWrapper) {
this._annotationManager.delete(this._annotationManager.selected[0]?.Id);
} else {
this._annotationManager.deselect(this._annotationManager.selected[0]?.Id);
}
#handleDeleteRectangle($event: KeyboardEvent) {
$event.preventDefault();
if (!!this._annotationManager.selected[0]) {
const doesHaveWrapper = this._fileDataService.find(this._annotationManager.selected[0]?.Id);
if (!doesHaveWrapper) {
this._annotationManager.delete(this._annotationManager.selected[0]?.Id);
} else {
this._annotationManager.deselect(this._annotationManager.selected[0]?.Id);
}
});
}
}
#rebuildFilters() {