maxisam / ngx-clipboard

A pure angular clipboard directive
http://maxisam.github.io/ngx-clipboard/
MIT License
505 stars 93 forks source link

cbSuccessMsg is no more taken into account #299

Closed MathieuCoupe closed 2 years ago

MathieuCoupe commented 2 years ago

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">

MathieuCoupe commented 2 years ago

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)">

maxisam commented 2 years ago

It is by design.

https://github.com/maxisam/ngx-clipboard/blob/c0868e2e1e771684880618d3b63037c52aea0392/projects/ngx-clipboard/src/lib/ngx-clipboard.directive.ts#L84-L93

MathieuCoupe commented 2 years ago

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
        };
maxisam commented 2 years ago

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

MathieuCoupe commented 2 years ago

see https://github.com/maxisam/ngx-clipboard/pull/300

rahuldimri commented 2 years ago

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

MathieuCoupe commented 2 years ago

issue fixed by #300