-
Notifications
You must be signed in to change notification settings - Fork 480
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
Successfully copying changes the icon to a tick #1404
Conversation
188b075
to
0074b70
Compare
// If there is a pending timeout then clear it. Otherwise the pending timeout will prematurely reset values. | ||
if (button.dataset.copyTimeout) { | ||
clearTimeout(button.dataset.copyTimeout); | ||
delete button.dataset.copyTimeout; |
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.
copyTimeout
is just a number
(specifically an integer), do we need to delete it? setting it to null, undefined or even 0 would probably still work. I'm curious if this is something specific for the result of setTimeout or not.
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.
Don't need to use delete. But I did because button.dataset
is basically a dictionary, and delete is the closest thing to .NET's dictionary.Remove(key)
.
}) | ||
.catch(() => { | ||
tooltipDiv.innerText = 'Could not access clipboard'; | ||
}); | ||
setTimeout(function () { tooltipDiv.innerText = precopy }, 1500); | ||
|
||
button.dataset.copyTimeout = setTimeout(function () { |
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.
Could you explain why all this code is JS and not blazor?
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 went with the existing code (changing the tooltip title) that already existed in JS.
I thought about doing everything in Blazor but there is UI lag to consider. If the dashboard is in ACA and you have a slow connection, then there could be a 1s+ delay between clicking copy and the confirmation that content was copied. JS will always be fast.
0074b70
to
b1e0886
Compare
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 love how this looks.
Co-authored-by: Drew Noakes <[email protected]>
Fixes #1386
Microsoft Reviewers: Open in CodeFlow