ngx-clipboard
ngx-clipboard copied to clipboard
Page is scrollto Top after use copyFromContent
I used copyFromContent function to copy a text. But after paste text, return to page and click to anywhere, the page will scroll to Top. This is what is used
public singleCopy(targetText) {
if (targetText) {
this.clipBoardService.copyFromContent(targetText);
}
}
Inview:
<div>
<button class="btn btn-outline-secondary single-copy-btn"
(click)="singleCopy(employee['name'])">
</button>
</div>
Chrome version: 79.0.3945.130 OS: macOS Mojave10.14.4
Does anyone have experience about this or know the way to solve this please help 🙇 ?
Could you provide an example on stackblitz.com?
I think it is possible to fix that behavior by setting container to body.
<body #container>
<button ngxClipboard [cbContent]="'target string'" [container]="container">Copy</button>
</body>
I have a similar issue, the page was scrolling to the top after copying to clipboard and switching to another tab.
It could be solved using configure method.
ClipboardService.configure({ cleanUpAfterCopy: true })