Skip to content

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

Add guards in table editor table state (#35320)

Joshen Lim5359176187ac
diff --git a/apps/studio/state/table-editor-table.tsx b/apps/studio/state/table-editor-table.tsx
index ea62ab755d0..f35aaccdaf3 100644
--- a/apps/studio/state/table-editor-table.tsx
+++ b/apps/studio/state/table-editor-table.tsx
@@ -93,21 +93,29 @@ export const createTableEditorTableState = ({
state.gridColumns.splice(toIdx, 0, moveItem)
},
updateColumnSize: (index: number, width: number) => {
- ;(state.gridColumns[index] as CalculatedColumn<any, any> & { width?: number }).width = width
+ if (state.gridColumns[index]) {
+ ;(state.gridColumns[index] as CalculatedColumn<any, any> & { width?: number }).width = width
+ }
},
freezeColumn: (columnKey: string) => {
const index = state.gridColumns.findIndex((x) => x.key === columnKey)
- ;(state.gridColumns[index] as CalculatedColumn<any, any> & { frozen?: boolean }).frozen = true
+ if (state.gridColumns[index]) {
+ ;(state.gridColumns[index] as CalculatedColumn<any, any> & { frozen?: boolean }).frozen =
+ true
+ }
},
unfreezeColumn: (columnKey: string) => {
const index = state.gridColumns.findIndex((x) => x.key === columnKey)
- ;(state.gridColumns[index] as CalculatedColumn<any, any> & { frozen?: boolean }).frozen =
- false
+ if (state.gridColumns[index]) {
+ ;(state.gridColumns[index] as CalculatedColumn<any, any> & { frozen?: boolean }).frozen =
+ false
+ }
},
updateColumnIdx: (columnKey: string, columnIdx: number) => {
const index = state.gridColumns.findIndex((x) => x.key === columnKey)
- ;(state.gridColumns[index] as CalculatedColumn<any, any> & { idx?: number }).idx = columnIdx
-
+ if (state.gridColumns[index]) {
+ ;(state.gridColumns[index] as CalculatedColumn<any, any> & { idx?: number }).idx = columnIdx
+ }
state.gridColumns.sort((a, b) => a.idx - b.idx)
},