MCPcopy Create free account
hub / github.com/adobe/react-spectrum / handleCopy

Function handleCopy

packages/dev/s2-docs/src/CopyButton.tsx:42–59  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40 }, []);
41
42 let handleCopy = () => {
43 if (timeout.current) {
44 clearTimeout(timeout.current);
45 }
46 let value = text ?? getText?.();
47 if (!value) {
48 return;
49 }
50 navigator.clipboard
51 .writeText(value)
52 .then(() => {
53 setIsCopied(true);
54 timeout.current = setTimeout(() => setIsCopied(false), 2000);
55 })
56 .catch(() => {
57 ToastQueue.negative('Failed to copy.');
58 });
59 };
60
61 return (
62 <TooltipTrigger placement="end">

Callers

nothing calls this directly

Calls 1

getTextFunction · 0.70

Tested by

no test coverage detected