Fix issues with grid key naviation
It should only navigate now when focussed. Same logic applies to the gallery. The focus is kept when changing between the gallery and the grid. TG-48 #closed Signed-off-by: trivernis <trivernis@protonmail.com>pull/4/head
parent
08632080cb
commit
a86aaef510
@ -0,0 +1,8 @@
|
||||
import { InputReceiverDirective } from './input-receiver.directive';
|
||||
|
||||
describe('InputReceiverDirective', () => {
|
||||
it('should create an instance', () => {
|
||||
const directive = new InputReceiverDirective();
|
||||
expect(directive).toBeTruthy();
|
||||
});
|
||||
});
|
@ -0,0 +1,32 @@
|
||||
import {
|
||||
Directive,
|
||||
EventEmitter,
|
||||
HostBinding,
|
||||
HostListener,
|
||||
Output
|
||||
} from "@angular/core";
|
||||
|
||||
@Directive({
|
||||
selector: "[appInputReceiver]"
|
||||
})
|
||||
export class InputReceiverDirective {
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
@Output() keyDownEvent = new EventEmitter<KeyboardEvent>();
|
||||
@Output() keyUpEvent = new EventEmitter<KeyboardEvent>();
|
||||
|
||||
@HostBinding("tabindex") tabIndex = 1;
|
||||
|
||||
@HostListener("keydown", ["$event"])
|
||||
onKeyDown(event: KeyboardEvent) {
|
||||
this.keyDownEvent.emit(event);
|
||||
}
|
||||
|
||||
@HostListener("keyup", ["$event"])
|
||||
onKeyUp(event: KeyboardEvent) {
|
||||
this.keyUpEvent.emit(event);
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<app-file-grid (fileOpenEvent)="this.onFileOpen($event)" (fileSelectEvent)="this.onFileSelect($event)"
|
||||
<app-file-grid #fileGrid (fileOpenEvent)="this.onFileOpen($event)" (fileSelectEvent)="this.onFileSelect($event)"
|
||||
*ngIf="this.mode === 'grid'"
|
||||
[files]="this.files" [preselectedFile]="this.preselectedFile"></app-file-grid>
|
||||
<app-file-gallery (closeEvent)="this.mode = 'grid'" (fileSelectEvent)="this.onSinglefileSelect($event)"
|
||||
<app-file-gallery #fileGallery (closeEvent)="this.mode = 'grid'" (fileSelectEvent)="this.onSinglefileSelect($event)"
|
||||
*ngIf="this.mode === 'gallery'"
|
||||
[files]="this.files"
|
||||
[preselectedFile]="this.preselectedFile"></app-file-gallery>
|
||||
|
Loading…
Reference in New Issue