Fix document not focused error on clipboard permission accept Windows
This commit is contained in:
parent
c767f35590
commit
91f44f9eda
@ -122,8 +122,9 @@ export async function clipboardSupported(): Promise<boolean> {
|
|||||||
try {
|
try {
|
||||||
await navigator.clipboard.readText();
|
await navigator.clipboard.readText();
|
||||||
query = await navigator.permissions.query({ name: "clipboard-read" });
|
query = await navigator.permissions.query({ name: "clipboard-read" });
|
||||||
// Focus window after permission dialog closed to allow further calls the api
|
// Wait 300ms before returning when permission has been accepted to prevent immediate calls
|
||||||
window.focus();
|
// to the clipboard api to fail with a document not focused error
|
||||||
|
await timeout(300);
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -133,3 +134,7 @@ export async function clipboardSupported(): Promise<boolean> {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function timeout(ms: number) {
|
||||||
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user