Fix share button: copy to clipboard on desktop, text box fallback on iOS

- Try navigator.clipboard.writeText first
- Show "Copied!" feedback on success
- Only show text box fallback if clipboard fails (iOS)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
b1rdmania
2025-12-29 14:28:32 +00:00
parent 150e5aacb3
commit 469212aa3c
+21 -1
View File
@@ -718,11 +718,31 @@ class MotifApp {
} }
} }
// Show the link // Try to copy to clipboard first (works on desktop)
let copied = false;
try {
if (navigator.clipboard?.writeText) {
await navigator.clipboard.writeText(shareUrl);
copied = true;
}
} catch {
// Clipboard failed, fall through to text box
}
if (copied) {
// Show brief "Copied!" feedback
const originalText = this.copyLinkBtn.textContent;
this.copyLinkBtn.textContent = 'Copied!';
setTimeout(() => {
this.copyLinkBtn.textContent = originalText;
}, 1500);
} else {
// Fallback: show text box for manual copy (iOS)
this.shareLinkInput.value = shareUrl; this.shareLinkInput.value = shareUrl;
this.shareLinkBox.style.display = 'block'; this.shareLinkBox.style.display = 'block';
this.shareLinkInput.select(); this.shareLinkInput.select();
} }
}
private setState(state: 'idle' | 'results' | 'selected' | 'generated'): void { private setState(state: 'idle' | 'results' | 'selected' | 'generated'): void {
// results - keep visible in all states except idle so user can pick a different source // results - keep visible in all states except idle so user can pick a different source