Merge pull request #806 from webrecorder/frontend-update-copy-button

This commit is contained in:
Henry Wilkinson 2023-05-01 15:38:22 -04:00 committed by GitHub
commit 624e7083cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,12 +40,15 @@ export class CopyButton extends LitElement {
render() {
return html`
<sl-button
size="small"
@click=${this.onClick}
?disabled=${!this.value && !this.getValue}
>${this.isCopied ? msg("Copied") : msg("Copy")}</sl-button
>
<sl-tooltip content=${this.isCopied ? msg("Copied to clipboard!") : msg("Copy")}>
<sl-icon-button
size="small"
name=${this.isCopied ? "check-lg" : "files"}
label=${msg("Copy to clipboard")}
@click=${this.onClick}
?disabled=${!this.value && !this.getValue}
></sl-icon-button>
</sl-tooltip>
`;
}
@ -59,6 +62,8 @@ export class CopyButton extends LitElement {
this.timeoutId = window.setTimeout(() => {
this.isCopied = false;
const button = this.shadowRoot?.querySelector('sl-icon-button');
button?.blur(); // Remove focus from the button to set it back to its default state
}, 3000);
}
}