-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Copy Icon is not restoring back from right tick ,when Copied #3178
fix: Copy Icon is not restoring back from right tick ,when Copied #3178
Conversation
@@ -9,12 +14,20 @@ export class CopyButtonComponent { | |||
public elRef = inject<ElementRef<HTMLElement>>(ElementRef<HTMLElement>); | |||
public copied = false; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onCopy() { | ||
const preRef = this.elRef.nativeElement.querySelector('pre:not(.hide)'); | ||
if (!preRef) { | ||
return; | ||
} | ||
navigator.clipboard.writeText(preRef.firstChild.textContent); | ||
this.copied = true; | ||
this.cdr.detectChanges(); | ||
|
||
setTimeout(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setTimeout(() => { | |
this.revertIconTimeout = setTimeout(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we assign the result of the setTimeout call to a property and clearTimeout
in the onDestroy
lifecycle hook?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've implemented the suggested change, and it was a great idea—thank you!
05372f1
to
500a7c6
Compare
LGTM |
Fixes #3177
PR Type
Bug
What is the current behavior?
Currently, It is copying and then not restoring back to copy icon after some timeout
Issue Number: #3177
What is the new behavior?
Now, I have added the setTimeout to 2s to toggle back to copy icon.