[ACA-2368] UI Issues while editing Metadata in the Preview Page #1091 (#5562)

* [ACA-2368] UI Issues while editing Metadata in the Preview Page #1091

* tslint fxed

* [ACA-2368] UI Issues while editing Metadata in the Preview Page #1091

* * revert commits

* Revert "* revert commits"

This reverts commit fd0e86084cc4ac14870d9008400528f63a681c59.

* * unit test added
This commit is contained in:
dhrn
2020-03-25 16:36:40 +05:30
committed by GitHub
parent c684d5f50c
commit 3f45e7b35d
5 changed files with 74 additions and 2 deletions

View File

@@ -11,6 +11,7 @@
</mat-expansion-panel-header>
<adf-card-view
(keydown)="keyDown($event)"
[properties]="basicProperties$ | async"
[editable]="editable"
[displayEmpty]="displayEmpty">
@@ -30,6 +31,7 @@
</mat-expansion-panel-header>
<adf-card-view
(keydown)="keyDown($event)"
[properties]="group.properties"
[editable]="editable"
[displayEmpty]="displayEmpty">

View File

@@ -352,7 +352,6 @@ describe('ContentMetadataComponent', () => {
expect(defaultProp.componentInstance.expanded).toBeTruthy();
expect(exifProp.componentInstance.expanded).toBeFalsy();
expect(customProp.componentInstance.expanded).toBeFalsy();
}));
it('should not expand anything if input is wrong', async(() => {
@@ -370,6 +369,35 @@ describe('ContentMetadataComponent', () => {
}));
});
describe('events', () => {
it('should not propagate the event on left arrows press', () => {
fixture.detectChanges();
const event = { keyCode: 37, stopPropagation: () => {} };
spyOn(event, 'stopPropagation').and.stub();
const element = fixture.debugElement.query(By.css('adf-card-view'));
element.triggerEventHandler('keydown', event);
expect(event.stopPropagation).toHaveBeenCalled();
});
it('should not propagate the event on right arrows press', () => {
fixture.detectChanges();
const event = { keyCode: 39, stopPropagation: () => {} };
spyOn(event, 'stopPropagation').and.stub();
const element = fixture.debugElement.query(By.css('adf-card-view'));
element.triggerEventHandler('keydown', event);
expect(event.stopPropagation).toHaveBeenCalled();
});
it('should propagate the event on other keys press', () => {
fixture.detectChanges();
const event = { keyCode: 40, stopPropagation: () => {} };
spyOn(event, 'stopPropagation').and.stub();
const element = fixture.debugElement.query(By.css('adf-card-view'));
element.triggerEventHandler('keydown', event);
expect(event.stopPropagation).not.toHaveBeenCalled();
});
});
});
function queryDom(fixture: ComponentFixture<ContentMetadataComponent>, properties: string = 'properties') {

View File

@@ -174,4 +174,10 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
return !this.expanded || this.displayAspect === 'Properties';
}
keyDown(event: KeyboardEvent) {
if (event.keyCode === 37 || event.keyCode === 39) { // ArrowLeft && ArrowRight
event.stopPropagation();
}
}
}