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:
+24
-4
@@ -718,10 +718,30 @@ class MotifApp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show the link
|
// Try to copy to clipboard first (works on desktop)
|
||||||
this.shareLinkInput.value = shareUrl;
|
let copied = false;
|
||||||
this.shareLinkBox.style.display = 'block';
|
try {
|
||||||
this.shareLinkInput.select();
|
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.shareLinkBox.style.display = 'block';
|
||||||
|
this.shareLinkInput.select();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private setState(state: 'idle' | 'results' | 'selected' | 'generated'): void {
|
private setState(state: 'idle' | 'results' | 'selected' | 'generated'): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user