Skip to content

Commit

Permalink
fix: Fix a render error in the foreign key selector (supabase#18628)
Browse files Browse the repository at this point in the history
The table in SelectorGrid wasn't migrated to the new column format of react-select-grid.
  • Loading branch information
ivasilov authored Nov 1, 2023
1 parent c393e30 commit bdd849c
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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">
Expand All @@ -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 (
Expand Down

0 comments on commit bdd849c

Please sign in to comment.