fix(share): robust clipboard copy with an iOS-safe fallback
navigator.clipboard.writeText is intermittent on iOS Safari (bug 9: the download share-link copy 'often does neither'). Add lib/clipboard.ts copyText(): a gesture-safe execCommand path FIRST (before any await can spend the transient user activation), async Clipboard API as fallback. Migrate all five copy call sites to it.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import Overlay from "./Overlay";
|
||||
import { copyText } from "../lib/clipboard";
|
||||
import { usePrefs } from "./PrefsProvider";
|
||||
|
||||
/**
|
||||
@@ -205,11 +206,11 @@ export default function GlassTuner() {
|
||||
return lines.length ? `${scope} {\n${lines.join("\n")}\n}` : "/* all values at defaults */";
|
||||
}, [vars, palette, themeTick]);
|
||||
|
||||
function copy() {
|
||||
navigator.clipboard?.writeText(cssOut).then(() => {
|
||||
async function copy() {
|
||||
if (await copyText(cssOut)) {
|
||||
setCopied(true);
|
||||
setTimeout(() => setCopied(false), 1200);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function persistOpen(v: boolean) {
|
||||
|
||||
Reference in New Issue
Block a user