Fixed keyboard navigation bugs.

This commit is contained in:
softsimon
2020-05-13 13:03:57 +07:00
parent 910696e41c
commit afb4f6e70b
5 changed files with 46 additions and 36 deletions

View File

@@ -65,21 +65,12 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy {
this.stateService.networkChanged$
.subscribe((network) => this.network = network);
}
@HostListener('window:resize', ['$event'])
onResize() {
if (this.mempoolBlocks && this.mempoolBlocks.length) {
this.mempoolBlocks = this.reduceMempoolBlocksToFitScreen(JSON.parse(JSON.stringify(this.mempoolBlocksFull)));
}
}
@HostListener('document:keydown', ['$event'])
handleKeyboardEvents(event: KeyboardEvent) {
setTimeout(() => {
this.stateService.keyNavigation$.subscribe((event) => {
if (this.markIndex === undefined) {
return;
}
if (event.key === 'ArrowRight') {
if (this.mempoolBlocks[this.markIndex - 1]) {
this.router.navigate([(this.network ? '/' + this.network : '') + '/mempool-block/', this.markIndex - 1]);
@@ -100,6 +91,13 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy {
});
}
@HostListener('window:resize', ['$event'])
onResize() {
if (this.mempoolBlocks && this.mempoolBlocks.length) {
this.mempoolBlocks = this.reduceMempoolBlocksToFitScreen(JSON.parse(JSON.stringify(this.mempoolBlocksFull)));
}
}
ngOnDestroy() {
this.mempoolBlocksSubscription.unsubscribe();
}