[ACA-1144] fix keyboard navigation (#819)

This commit is contained in:
Denys Vuika
2018-11-22 17:42:07 +00:00
committed by GitHub
parent 4726803709
commit eb57553140

View File

@@ -23,7 +23,13 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Component, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core';
import {
Component,
OnInit,
OnDestroy,
ViewEncapsulation,
HostListener
} from '@angular/core';
import {
ActivatedRoute,
Router,
@@ -153,6 +159,18 @@ export class PreviewComponent extends PageComponent
}
}
@HostListener('document:keydown', ['$event'])
handleKeyboardEvent(event: KeyboardEvent) {
const key = event.keyCode;
const rightArrow = 39;
const leftArrow = 37;
if (key === rightArrow || key === leftArrow) {
event.preventDefault();
event.stopImmediatePropagation();
}
}
/**
* Handles the visibility change of the Viewer component.
* @param isVisible Indicator whether Viewer is visible or hidden.