ngx-sharebuttons icon indicating copy to clipboard operation
ngx-sharebuttons copied to clipboard

Copy link button not working

Open kevinshah22 opened this issue 2 years ago • 1 comments

Reproduction

Use StackBlitz to reproduce your issue: https://stackblitz.com/edit/ngx-sharebuttons

Steps to reproduce:

  1. I have configure the ngx-sharebuttons
  2. set all required properties
  3. still copy button does not work.
  4. all other option works properly but copy button is not working.

I am using "11.0.0" version.

Expected Behavior

What behavior were you expecting to see? Copy button should work and link should be copy to clipboard.

Actual Behavior

What behavior did you actually see? Copy to clipboard button do nothing. all other button works as expected.

Environment

  • Angular: 14
  • ngx-sharebuttons: v11
  • Browser(s): Any
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

kevinshah22 avatar Aug 24 '22 08:08 kevinshah22

Please add a reproduction, the live stackblitz works properly!

MurhafSousli avatar Aug 25 '22 02:08 MurhafSousli

For me working as expected, but there is no indication - it will be great from the UX perspective to notify users when action is completed. @MurhafSousli is there any way to enable it?

duxor avatar Feb 12 '23 11:02 duxor

@duxor You can subscribe to the opened output when a share button is clicked, then display the notification you like!

MurhafSousli avatar Feb 12 '23 15:02 MurhafSousli

@MurhafSousli great, thanks, I will check it in the next few days :)

duxor avatar Feb 16 '23 17:02 duxor

@MurhafSousli , Unfortunately, the opened emitter doesn't work as expected for copy share type - I tested it using the share directive.

The copyToClipboard util function will be called from [here] and there is no emitter, you can check the config [here] and util function [here].

So, what do you suggest? :)

duxor avatar Feb 17 '23 11:02 duxor

@duxor I will look into why opened is not emitting

Check the directive usage https://github.com/MurhafSousli/ngx-sharebuttons/wiki/Share-Button-Directive#usage

You can use the following:

<button shareButton="copy" #copy="shareButton" url="http://abc.com">
  {{ copy.text }}
</button>

copy.text will change when the copy button is clicked

You can also access the icon copy.icon

If you need an event, use the click event of the button

<button shareButton="copy" #copy="shareButton" url="http://abc.com" (click)="onCopyClick()">
  {{ copy.text }}
</button>

Here is a working stackblitz

Here are the default properties of the copy button:

https://github.com/MurhafSousli/ngx-sharebuttons/blob/ac059e97774feeef3bec5d2facb73e2fc1f23192/projects/ngx-sharebuttons/src/lib/share.defaults.ts#L249-L262

MurhafSousli avatar Feb 19 '23 15:02 MurhafSousli

@MurhafSousli
thanks for your reply but i use the same code as you copy text changes and working good but i don't get any value it still empty value nothing copied to clipboard

this is my code

` <ng-template #shareButtons> <share-buttons [theme]="'circles-dark'" [include]="include" [title]="title" [description]="title" [image]="image" [tags]="tags" [url]="url">

<button shareButton="copy" #copy="shareButton" [url]="url"> {{ copy.text }} `

Mersal-Mohamed2 avatar Feb 21 '23 08:02 Mersal-Mohamed2