The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix(ui): fail copyToClipboard when the Clipboard API is unavailable (#50641)
claude[bot]aaa1b8c0dfa4
diff --git a/apps/studio/tests/components/Grid/Grid.utils.test.ts b/apps/studio/tests/components/Grid/Grid.utils.test.tsindex 2801a54cfae..8722cebe1f0 100644--- a/apps/studio/tests/components/Grid/Grid.utils.test.ts+++ b/apps/studio/tests/components/Grid/Grid.utils.test.ts@@ -178,4 +178,14 @@ describe('shared clipboard util', () => {expect(writeText).toHaveBeenCalledWith('hello from safari')expect(onCopy).toHaveBeenCalled()})++ test('should not invoke the callback when the Clipboard API is unavailable', async () => {+ const onCopy = vi.fn()++ vi.stubGlobal('navigator', {})++ await copyToClipboard('no clipboard here', onCopy)+ expect(onCopy).not.toHaveBeenCalled()+ expect(toastError).toHaveBeenCalledWith('Unable to copy to clipboard')+ })})diff --git a/packages/ui/src/lib/utils/clipboard.ts b/packages/ui/src/lib/utils/clipboard.tsindex 8fe3b5e1154..91b615a6a00 100644--- a/packages/ui/src/lib/utils/clipboard.ts+++ b/packages/ui/src/lib/utils/clipboard.ts@@ -35,11 +35,13 @@ export const copyToClipboard = async (str: ClipboardText, callback = noop) => {return}+ if (!navigator.clipboard) throw new Error('Clipboard API unavailable')+// NOTE: Firefox has support for ClipboardItem and navigator.clipboard.write,// but those are behind `dom.events.asyncClipboard.clipboardItem` preference.// Good news is that other than Safari, Firefox does not care about// Clipboard API being used async in a Promise.- await Promise.resolve(str).then((text) => navigator.clipboard?.writeText(text))+ await Promise.resolve(str).then((text) => navigator.clipboard.writeText(text))callback()} catch {toast.error('Unable to copy to clipboard')