Skip to content

Commit faf7be4

Browse files
authored
Handle missing "navigator.clipboard" (#159)
In some cases navigator.clipboard can be undefined. For example on HTTP site (happens in DMZ environments). In such cases copy will fail. However, it can always be remediated on user side by using good old execCommand. This commit modifies code to avoid exception on copy.
1 parent e3574af commit faf7be4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/ButtonPanels.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ export const EditButtons: React.FC<EditButtonProps> = ({
7979
value = data
8080
stringValue = type ? JSON.stringify(data, null, 2) : String(value)
8181
}
82-
void navigator.clipboard.writeText(stringValue)
83-
}
84-
if (typeof enableClipboard === 'function') {
85-
enableClipboard({ value, stringValue, path, key, type: copyType })
82+
void navigator.clipboard?.writeText(stringValue)
83+
if (typeof enableClipboard === 'function') {
84+
enableClipboard({ value, stringValue, path, key, type: copyType })
85+
}
8686
}
8787
}
8888

0 commit comments

Comments
 (0)