[ACS-8468] Add guard to copyToClipboard

This commit is contained in:
Shivangi Shree
2026-07-16 12:11:29 +05:30
parent 770c3a4e77
commit 3eed46904a
2 changed files with 14 additions and 9 deletions
@@ -30,7 +30,6 @@
class="adf-datepicker-span-button"
[attr.data-automation-id]="'datepicker-label-toggle-' + property.key"
(click)="showDatePicker()"
(dblclick)="copyToClipboard(property.displayValue)"
tabindex="0"
role="button"
(keyup.enter)="showDatePicker()"
@@ -93,7 +92,10 @@
}
</mat-form-field>
} @else {
<mat-form-field class="adf-property-field adf-dateitem-editable" [floatLabel]="property.default ? 'always' : null">
<mat-form-field
class="adf-property-field adf-dateitem-editable"
[floatLabel]="property.default ? 'always' : null"
>
<mat-label
class="adf-property-label"
[attr.data-automation-id]="'card-dateitem-label-' + property.key"
@@ -121,6 +123,7 @@
[attr.data-automation-id]="'datepicker-label-toggle-' + property.key"
(click)="showDatePicker()"
(dblclick)="copyToClipboard(property.displayValue)"
[title]="'CORE.METADATA.ACTIONS.COPY_TO_CLIPBOARD' | translate"
tabindex="0"
role="button"
(keyup.enter)="showDatePicker()"
@@ -195,14 +195,16 @@ export class CardViewSelectItemComponent extends BaseCardView<CardViewSelectItem
}
copyToClipboard(valueToCopy: string | string[] | Observable<string>) {
if (isObservable(valueToCopy)) {
valueToCopy.pipe(take(1)).subscribe((value) => {
if (this.copyToClipboardAction) {
if (isObservable(valueToCopy)) {
valueToCopy.pipe(take(1)).subscribe((value) => {
const clipboardMessage = this.translateService.instant('CORE.METADATA.ACCESSIBILITY.COPY_TO_CLIPBOARD_MESSAGE');
this.clipboardService.copyContentToClipboard(value, clipboardMessage);
});
} else if (typeof valueToCopy === 'string') {
const clipboardMessage = this.translateService.instant('CORE.METADATA.ACCESSIBILITY.COPY_TO_CLIPBOARD_MESSAGE');
this.clipboardService.copyContentToClipboard(value, clipboardMessage);
});
} else if (typeof valueToCopy === 'string') {
const clipboardMessage = this.translateService.instant('CORE.METADATA.ACCESSIBILITY.COPY_TO_CLIPBOARD_MESSAGE');
this.clipboardService.copyContentToClipboard(valueToCopy, clipboardMessage);
this.clipboardService.copyContentToClipboard(valueToCopy, clipboardMessage);
}
}
}