From 38669218ac2ff09af5b91da142febd71fd37681c Mon Sep 17 00:00:00 2001 From: Vaibhav <117663341+7ttp@users.noreply.github.com> Date: Mon, 6 Jul 2026 18:47:17 +0530 Subject: [PATCH] fix: preserve copy (#47607) - closes https://github.com/supabase/supabase/issues/47606 ## Summary by CodeRabbit * **Bug Fixes** * Copying cell values now preserves `false` and `0` instead of treating them like empty values. * Clipboard copy behavior now only returns blank for truly empty inputs, helping keep table data accurate when copied. * **Tests** * Added end-to-end coverage for copying table cells with `false`, `0`, and `true` values. --- apps/studio/components/grid/utils/common.ts | 2 +- e2e/studio/features/table-editor.spec.ts | 46 +++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/apps/studio/components/grid/utils/common.ts b/apps/studio/components/grid/utils/common.ts index 7579d346273..f7e2ca1ab60 100644 --- a/apps/studio/components/grid/utils/common.ts +++ b/apps/studio/components/grid/utils/common.ts @@ -1,5 +1,5 @@ export function formatClipboardValue(value: unknown) { - if (!value) return '' + if (value == null) return '' if (typeof value === 'object') { return JSON.stringify(value) } diff --git a/e2e/studio/features/table-editor.spec.ts b/e2e/studio/features/table-editor.spec.ts index 0d1688e34ca..c328a8cced8 100644 --- a/e2e/studio/features/table-editor.spec.ts +++ b/e2e/studio/features/table-editor.spec.ts @@ -877,6 +877,52 @@ testRunner('table editor', () => { }) }) + test('copying cell values preserves false and zero', async ({ page, ref }) => { + const tableName = 'pw_table_copy_falsy_values' + + await using _ = await withSetupCleanup( + async () => { + await query(` + create table if not exists public.${tableName} ( + bool_false boolean, + bool_true boolean, + zero_int integer + ); + `) + await query(` + insert into public.${tableName} (bool_false, bool_true, zero_int) + values (false, true, 0); + `) + }, + async () => { + await dropTable(tableName) + } + ) + + await page.goto(toUrl(`/project/${ref}/editor?schema=public`)) + await page.getByRole('button', { name: `View ${tableName}`, exact: true }).click() + await page.waitForURL(/\/editor\/\d+\?schema=public$/) + await expect(page.getByRole('grid')).toBeVisible() + + const falseCell = page.getByRole('gridcell', { name: 'FALSE' }).first() + await expect(falseCell).toBeVisible() + await falseCell.click({ button: 'right' }) + await page.getByRole('menuitem', { name: 'Copy cell' }).click() + await expectClipboardValue({ page, value: 'false', exact: true }) + + const zeroCell = page.getByRole('gridcell', { name: '0' }).first() + await expect(zeroCell).toBeVisible() + await zeroCell.click({ button: 'right' }) + await page.getByRole('menuitem', { name: 'Copy cell' }).click() + await expectClipboardValue({ page, value: '0', exact: true }) + + const trueCell = page.getByRole('gridcell', { name: 'TRUE' }).first() + await expect(trueCell).toBeVisible() + await trueCell.click({ button: 'right' }) + await page.getByRole('menuitem', { name: 'Copy cell' }).click() + await expectClipboardValue({ page, value: 'true', exact: true }) + }) + test('boolean fields can be edited correctly', async ({ page, ref }) => { const tableName = 'pw_table_boolean_edits' const boolColName = 'is_active'