diff --git a/apps/studio/components/grid/utils/gridColumns.tsx b/apps/studio/components/grid/utils/gridColumns.tsx index 54d50cdc72b..a2f2bad8ccf 100644 --- a/apps/studio/components/grid/utils/gridColumns.tsx +++ b/apps/studio/components/grid/utils/gridColumns.tsx @@ -200,15 +200,12 @@ function withPendingAddPlaceholders( const value = props.row[props.column.key] if (isPendingAddRow(props.row) && (value === undefined || value === null || value === '')) { - if (columnDef.defaultValue !== undefined && columnDef.defaultValue !== null) { - return - } - if (columnDef.isIdentity || columnDef.isGeneratable) { - return - } - if (columnDef.isNullable) { + if (value === null) { return } + if (columnDef.defaultValue !== undefined || columnDef.isIdentity || columnDef.isGeneratable) { + return + } } return diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx index 7c72debe95d..aeecd1677c9 100644 --- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx +++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx @@ -1,11 +1,11 @@ import { includes, noop } from 'lodash' import { Edit, Eye } from 'lucide-react' - import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, + DropdownMenuSeparator, DropdownMenuTrigger, Input, Select, @@ -17,6 +17,7 @@ import { SelectValue_Shadcn_, } from 'ui' import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout' + import { DATETIME_TYPES, JSON_TYPES, TEXT_TYPES } from '../SidePanelEditor.constants' import { DateTimeInput } from './DateTimeInput' import type { EditValue, RowField } from './RowEditor.types' @@ -28,6 +29,7 @@ const TRUNCATE_DESCRIPTION = export interface InputFieldProps { field: RowField errors: any + isNewRow?: boolean isEditable?: boolean onUpdateField?: (changes: object) => void onEditJson?: (data: any) => void @@ -38,6 +40,7 @@ export interface InputFieldProps { export const InputField = ({ field, errors, + isNewRow = false, isEditable = true, onUpdateField = noop, onEditJson = noop, @@ -146,6 +149,11 @@ export const InputField = ({ if (includes(TEXT_TYPES, field.format)) { const isTruncated = isValueTruncated(field.value) + /** + * Handle `undefined` as the default value of the input field + * Otherwise, NULL should be treated as NULL, empty strings should be treated as empty strings + */ + return (
-