fix: Fix a render error in the foreign key selector (#18628)

The table in SelectorGrid wasn't migrated to the new column format of react-select-grid.
This commit is contained in:
Ivan Vasilov authored and GitHub committed 2023-11-01 12:31:30 +00:00
1 parent c393e308e7
commit bdd849cd7e
1 file changed
+8 -7
@@ -1,12 +1,12 @@
import DataGrid, { Column } from 'react-data-grid'
import * as Tooltip from '@radix-ui/react-tooltip'
import { SupaRow, SupaTable } from 'components/grid'
import { IconKey } from 'ui'
import { COLUMN_MIN_WIDTH } from 'components/grid/constants'
import {
ESTIMATED_CHARACTER_PIXEL_WIDTH,
getColumnDefaultWidth,
} from 'components/grid/utils/gridColumns'
import { COLUMN_MIN_WIDTH } from 'components/grid/constants'
import DataGrid, { Column } from 'react-data-grid'
import { IconKey } from 'ui'
export interface SelectorGridProps {
table: SupaTable
@@ -40,7 +40,7 @@ const columnRender = (name: string, isPrimaryKey = false) => {
)
}
const formatter = (column: string, row: any) => {
const formatter = (column: string, row: SupaRow) => {
const formattedValue = typeof row[column] === 'object' ? JSON.stringify(row[column]) : row[column]
return (
<div className="group sb-grid-select-cell__formatter overflow-hidden">
@@ -57,15 +57,16 @@ const SelectorGrid = ({ table, rows, onRowSelect }: SelectorGridProps) => {
const columnWidth =
columnDefaultWidth < columnWidthBasedOnName ? columnWidthBasedOnName : columnDefaultWidth
return {
const result: Column<SupaRow> = {
key: column.name,
name: column.name,
formatter: ({ row }: any) => formatter(column.name, row),
headerRenderer: () => columnRender(column.name, column.isPrimaryKey),
renderCell: (props) => formatter(column.name, props.row),
renderHeaderCell: () => columnRender(column.name, column.isPrimaryKey),
resizable: true,
width: columnWidth,
minWidth: COLUMN_MIN_WIDTH,
}
return result
})
return (