maxisam/ngx-clipboard

cbSuccessMsg is no more taken into account

MathieuCoupe opened this issue · 7 comments

Starting from release 15.0.x of ngx-clipboard, assigning a string to the field cbSuccessMsg on the button no longer add it on the IClipboardResponse event generated.

eg:

<button ngxClipboard [cbContent]="content" cbSuccessMsg="content successfully copied">

When testing with cbOnSuccess callback, if found that adding a callback fix the missing field (in the event provided to the callback method and in the global event queue)

<button ngxClipboard [cbContent]="content" cbSuccessMsg="content successfully copied" (cbOnSuccess)="process($event)">

It is by design.

if (succeeded) {
if (this.cbOnSuccess.observers.length > 0) {
response = Object.assign(response, {
content: copiedContent,
successMessage: this.cbSuccessMsg
});
this.ngZone.run(() => {
this.cbOnSuccess.emit(response);
});
}

Thx for the quick response !

My issue is that we observe the global ClipboardService.copyResponse$ to avoid defining a callback for each ngxClipboard instance, and the event does not contain the successMessage field.

Would it be possible to enrich the event even if no local callback is registered ?

Something as :

        let response: IClipboardResponse = {
            isSuccess: succeeded,
            successMessage: this.cbSuccessMsg,
            event
        };

totally, welcome to make a PR I will merge it. thx!

This issue is closed as part of Pull Request #300. Please close the issue.

issue fixed by #300