mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
AAE-39679 Counting click event twice for attach file widget (#11645)
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
<div class="adf-attach-file-widget-container">
|
||||
<div class="adf-attach-widget {{field.className}}"
|
||||
[class.adf-readonly]="field.readOnly">
|
||||
<label class="adf-label" [attr.for]="field.id">{{field.name}}
|
||||
<label class="adf-label" [attr.for]="field.id + '-label'">{{field.name}}
|
||||
<span class="adf-asterisk" *ngIf="isRequired()">*</span>
|
||||
</label>
|
||||
<div class="adf-attach-widget-container" (focusout)="markAsTouched()">
|
||||
|
||||
+26
@@ -186,6 +186,32 @@ describe('AttachFileCloudWidgetComponent', () => {
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
|
||||
it('should not trigger button click when label is clicked', async () => {
|
||||
const openSelectDialogSpy = spyOn(widget, 'openSelectDialog');
|
||||
createUploadWidgetField(new FormModel(), 'attach-file-test', [], contentSourceParam);
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const label = element.querySelector('.adf-label') as HTMLElement;
|
||||
label.click();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(openSelectDialogSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should call openSelectDialog only once when button is clicked', async () => {
|
||||
const openSelectDialogSpy = spyOn(widget, 'openSelectDialog');
|
||||
createUploadWidgetField(new FormModel(), 'attach-file-test', [], contentSourceParam);
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const button = element.querySelector('.adf-attach-widget__menu-upload__button') as HTMLButtonElement;
|
||||
button.click();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(openSelectDialogSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
it('should show up as simple upload when is configured for only local files', async () => {
|
||||
|
||||
Reference in New Issue
Block a user