Show Share initials, a readable link, and a copy confirmation.
Filled avatars used white ink on yellow, the link field was a dimmed disabled input, and Copy failed silently when the clipboard API was denied.
This commit is contained in:
1 parent
3a264ac2df
commit
0fe2624002
11 files changed
+132
-14
No files matched your search
@@ -245,9 +245,25 @@ const ShareContainer = memo<ShareProps>((props) => {
|
||||
|
||||
const handleCopyLink = useCallback(async () => {
|
||||
if (!settings) return;
|
||||
const text = settings.shareUrl;
|
||||
try {
|
||||
await navigator.clipboard.writeText(settings.shareUrl);
|
||||
await navigator.clipboard.writeText(text);
|
||||
setLinkCopied(true);
|
||||
return;
|
||||
} catch {
|
||||
// Some browsers deny clipboard without a secure context; fall back.
|
||||
}
|
||||
try {
|
||||
const field = document.createElement("textarea");
|
||||
field.value = text;
|
||||
field.setAttribute("readonly", "");
|
||||
field.style.position = "fixed";
|
||||
field.style.left = "-9999px";
|
||||
document.body.appendChild(field);
|
||||
field.select();
|
||||
const copied = document.execCommand("copy");
|
||||
field.remove();
|
||||
setLinkCopied(copied);
|
||||
} catch {
|
||||
setLinkCopied(false);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user