Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Fix user defined enum types not selecting

Joshen Lim68ede5a07150
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx
index 46468d1e946..c88cb1aabff 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx
@@ -83,31 +83,37 @@ const ColumnType: FC<Props> = ({
---
</Listbox.Option>
+ {/*
+ Weird issue with Listbox here
+ 1. Can't do render conditionally (&&) within Listbox hence why using Fragment
+ 2. Can't wrap these 2 components within a Fragment conditional (enumTypes.length)
+ as selecting the enumType option will not render it in the Listbox component
+ */}
{enumTypes.length > 0 ? (
- <>
- <Listbox.Option disabled key="header-1" value="header-1" label="header-1">
- User-defined Enumerated Types
+ <Listbox.Option disabled key="header-1" value="header-1" label="header-1">
+ User-defined Enumerated Types
+ </Listbox.Option>
+ ) : (
+ <></>
+ )}
+
+ {enumTypes.length > 0 ? (
+ // @ts-ignore
+ enumTypes.map((enumType: PostgresType) => (
+ <Listbox.Option
+ key={enumType.name}
+ value={enumType.name}
+ label={enumType.name}
+ addOnBefore={() => {
+ return <div className="bg-scale-1200 mx-1 h-2 w-2 rounded-full" />
+ }}
+ >
+ <div className="flex items-center space-x-4">
+ <p>{enumType.name}</p>
+ </div>
</Listbox.Option>
- {
- // @ts-ignore
- enumTypes.map((enumType: PostgresType) => (
- <Listbox.Option
- key={enumType.name}
- value={enumType.name}
- label={enumType.name}
- addOnBefore={() => {
- return <div className="bg-scale-1200 mx-1 h-2 w-2 rounded-full" />
- }}
- >
- <div className="flex items-center space-x-4">
- <p>{enumType.name}</p>
- </div>
- </Listbox.Option>
- ))
- }
- </>
+ ))
) : (
- // Listbox cannot have booleans within it, hence why return as fragment (and not use &&)
<></>
)}
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
index 2e7bc1dc527..be55d449d95 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
@@ -57,8 +57,6 @@ const SidePanelEditor: FC<Props> = ({
(type: PostgresType) => !meta.excludedSchemas.includes(type.schema)
)
- console.log(enumTypes)
-
const saveRow = async (
payload: any,
isNewRecord: boolean,