RED-5398: Fixed Help Mode not opening when pdf viewer is focused.

This commit is contained in:
Nicoleta Panaghiu 2022-11-08 18:03:32 +02:00
parent ccb375b41c
commit d74d6dfed2
3 changed files with 15 additions and 2 deletions

View File

@ -21,6 +21,7 @@ import {
Debounce,
ErrorService,
FilterService,
HelpModeService,
List,
LoadingService,
NestedFilter,
@ -132,6 +133,7 @@ export class FilePreviewScreenComponent
private readonly _fileManagementService: FileManagementService,
private readonly _translateService: TranslateService,
private readonly _readableRedactionsService: ReadableRedactionsService,
private readonly _helpModeService: HelpModeService,
) {
super();
document.documentElement.addEventListener('fullscreenchange', () => {
@ -376,6 +378,17 @@ export class FilePreviewScreenComponent
this.toggleFullScreen();
return;
}
if (['h', 'H'].includes($event.key)) {
if ($event.target instanceof HTMLInputElement || $event.target instanceof HTMLTextAreaElement) {
return;
}
this._ngZone.run(() => {
window.focus();
this._helpModeService.activateHelpMode(false);
});
return;
}
}
async viewerReady(pageNumber: string = this._activatedRoute.snapshot.queryParams.page) {

View File

@ -11,7 +11,7 @@ export const ActionsHelpModeKeys = {
'hint-image': 'picture',
} as const;
export const ALL_HOTKEYS: List = ['Escape', 'F', 'f', 'ArrowUp', 'ArrowDown'] as const;
export const ALL_HOTKEYS: List = ['Escape', 'F', 'f', 'ArrowUp', 'ArrowDown', 'H', 'h'] as const;
export const HeaderElements = {
SHAPE_TOOL_GROUP_BUTTON: 'SHAPE_TOOL_GROUP_BUTTON',

View File

@ -58,7 +58,7 @@ export class REDDocumentViewer {
return fromEvent<KeyboardEvent>(this.#document, 'keyUp').pipe(
tap(stopAndPreventIfNotAllowed),
filter($event => ($event.target as HTMLElement)?.tagName?.toLowerCase() !== 'input'),
filter($event => $event.key.startsWith('Arrow') || $event.key === 'f'),
filter($event => $event.key.startsWith('Arrow') || $event.key === 'f' || ['h', 'H'].includes($event.key)),
tap(stopAndPrevent),
log('[PDF] Keyboard shortcut'),
);