Skip to content

Commit b8296b4

Browse files
committed
fix(frame-studio): remove canShare gate for iOS export
canShare was returning false on some iOS devices, preventing the share path entirely and falling through to anchor download which silently fails on iOS Safari. Now tries navigator.share() directly and only falls back to anchor download on TypeError.
1 parent 05838bb commit b8296b4

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

src/app/[locale]/frame-studio/_components/ExportDialog.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,16 +197,28 @@ export function ExportDialog({
197197
const fileName = `${baseName}_edited${ext}`
198198
const file = new File([blob], fileName, { type: originalMimeType })
199199

200-
// iOS Safari doesn't support anchor downloads — use native share sheet
201-
if (navigator.share && navigator.canShare?.({ files: [file] })) {
202-
try { await navigator.share({ files: [file] }) } catch { /* user cancelled */ }
203-
} else {
200+
// Try Web Share API first (iOS Safari doesn't support anchor downloads)
201+
let shared = false
202+
if (typeof navigator.share === 'function') {
203+
try {
204+
await navigator.share({ files: [file] })
205+
shared = true
206+
} catch (e) {
207+
// AbortError = user cancelled share sheet (still counts as handled)
208+
if (e instanceof DOMException && e.name === 'AbortError') shared = true
209+
// TypeError = files not supported → fall through to anchor download
210+
}
211+
}
212+
213+
if (!shared) {
204214
const url = URL.createObjectURL(blob)
205215
const a = document.createElement('a')
206216
a.href = url
207217
a.download = fileName
218+
document.body.appendChild(a)
208219
a.click()
209-
setTimeout(() => URL.revokeObjectURL(url), 10000)
220+
document.body.removeChild(a)
221+
setTimeout(() => URL.revokeObjectURL(url), 30000)
210222
}
211223
onClose()
212224
} finally {

0 commit comments

Comments
 (0)