[AAE-3908] - fix clear value icon on card view text item (#6269)

This commit is contained in:
Silviu Popa 2020-10-20 18:49:16 +03:00 committed by GitHub
parent 072f910452
commit 80fc239461
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 1 deletions

View File

@ -34,7 +34,7 @@
*ngIf="isEditable"
mat-icon-button
aria-label="Clear"
(click)="editedValue=''">
(click)="clearValue()">
<mat-icon>cancel</mat-icon>
</button>
<mat-icon matSuffix

View File

@ -393,6 +393,25 @@ describe('CardViewTextItemComponent', () => {
fixture.detectChanges();
expect(clipboardService.copyContentToClipboard).toHaveBeenCalledWith('myValueToCopy', 'CORE.METADATA.ACCESSIBILITY.COPY_TO_CLIPBOARD_MESSAGE');
});
it('should clear value when clear value icon is clicked', async () => {
component.property.value = 'testValue';
component.property.icon = 'FAKE_ICON';
component.property.clickable = true;
component.property.editable = true;
component.editable = true;
component.property.isValid = () => true;
fixture.detectChanges();
await fixture.whenStable();
fixture.detectChanges();
const clickEl = fixture.debugElement.query(By.css(`.adf-property-clear-value`));
clickEl.triggerEventHandler('click', new MouseEvent('click'));
fixture.detectChanges();
const elementValue = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${component.property.key}"]`));
expect(elementValue.nativeElement.textContent).toEqual('');
});
});
describe('Update', () => {

View File

@ -175,6 +175,7 @@ export class CardViewTextItemComponent extends BaseCardView<CardViewTextItemMode
clearValue() {
this.editedValue = '';
this.textInput.setValue('');
}
copyToClipboard(valueToCopy: string) {