The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Fix json side panel editor in table editor not updating properly (#18786)
Joshen Lim9fd5da39cd7a
diff --git a/studio/components/grid/components/editor/JsonEditor.tsx b/studio/components/grid/components/editor/JsonEditor.tsxindex ce1211e7c01..7a4250b89fc 100644--- a/studio/components/grid/components/editor/JsonEditor.tsx+++ b/studio/components/grid/components/editor/JsonEditor.tsx@@ -36,7 +36,7 @@ export const JsonEditor = <TRow, TSummaryRow = unknown>({}, [])const saveChanges = useCallback((newValue: string | null) => {- commitChange(newValue)+ if (newValue !== value) commitChange(newValue)}, [])const onChange = (_value: string | undefined) => {diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/JsonEditor/JsonCodeEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/JsonEditor/JsonCodeEditor.tsxindex 0dfdda0a335..3b309e6fb18 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/JsonEditor/JsonCodeEditor.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/JsonEditor/JsonCodeEditor.tsx@@ -1,6 +1,7 @@import Editor from '@monaco-editor/react'+import { uuidv4 } from 'lib/helpers'import { noop } from 'lodash'-import { useRef } from 'react'+import { useRef, useState, useEffect } from 'react'// [Joshen] Should just use CodeEditor instead of declaring Editor here so that all the mount logic is consistent@@ -12,12 +13,13 @@ interface JsonEditorProps {}const JsonEditor = ({- queryId = '',+ queryId,defaultValue = '',readOnly = false,onInputChange = noop,}: JsonEditorProps) => {const editorRef = useRef()+ const [id, setId] = useState<string>(uuidv4())const onMount = (editor: any, monaco: any) => {editorRef.current = editor@@ -34,13 +36,17 @@ const JsonEditor = ({const Loading = () => <h4>Loading</h4>+ useEffect(() => {+ setId(uuidv4())+ }, [defaultValue])+return (<EditorclassName="monaco-editor"theme="supabase"defaultLanguage="json"defaultValue={defaultValue}- path={queryId}+ path={queryId || id}loading={<Loading />}options={{readOnly,