From 469212aa3ced34f744aea65b98ce4c0e3bb2dc2a Mon Sep 17 00:00:00 2001 From: b1rdmania <102524336+b1rdmania@users.noreply.github.com> Date: Mon, 29 Dec 2025 14:28:32 +0000 Subject: [PATCH] Fix share button: copy to clipboard on desktop, text box fallback on iOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- src/main.ts | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/main.ts b/src/main.ts index 47f4d9e..8108e86 100644 --- a/src/main.ts +++ b/src/main.ts @@ -718,10 +718,30 @@ class MotifApp { } } - // Show the link - this.shareLinkInput.value = shareUrl; - this.shareLinkBox.style.display = 'block'; - this.shareLinkInput.select(); + // 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.shareLinkBox.style.display = 'block'; + this.shareLinkInput.select(); + } } private setState(state: 'idle' | 'results' | 'selected' | 'generated'): void {