Skip to content

Commit a54c4b4

Browse files
authored
fix(useClipboard): unhandled rejection on read permission prompt (#4615)
1 parent f6daf21 commit a54c4b4

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

packages/core/useClipboard/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,11 @@ export function useClipboard(options: UseClipboardOptions<MaybeRefOrGetter<strin
7070
const copied = shallowRef(false)
7171
const timeout = useTimeoutFn(() => copied.value = false, copiedDuring, { immediate: false })
7272

73-
function updateText() {
73+
async function updateText() {
7474
let useLegacy = !(isClipboardApiSupported.value && isAllowed(permissionRead.value))
7575
if (!useLegacy) {
7676
try {
77-
navigator!.clipboard.readText().then((value) => {
78-
text.value = value
79-
})
77+
text.value = await navigator!.clipboard.readText()
8078
}
8179
catch {
8280
useLegacy = true

0 commit comments

Comments
 (0)