The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix: Fix a bug with the JSON editor in the side panel (#18825)
Ivan Vasilovdc6b7c50c435
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/JsonEditor/JsonCodeEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/JsonEditor/JsonCodeEditor.tsxindex 3b309e6fb18..0c69a8bcc12 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/JsonEditor/JsonCodeEditor.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/JsonEditor/JsonCodeEditor.tsx@@ -1,31 +1,17 @@-import Editor from '@monaco-editor/react'-import { uuidv4 } from 'lib/helpers'+import Editor, { OnChange, OnMount } from '@monaco-editor/react'import { noop } from 'lodash'-import { useRef, useState, useEffect } from 'react'// [Joshen] Should just use CodeEditor instead of declaring Editor here so that all the mount logic is consistentinterface JsonEditorProps {- queryId?: string- defaultValue: string+ value: stringreadOnly?: boolean- onInputChange: (value: any) => void+ onInputChange: OnChange}-const JsonEditor = ({- 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-- // Add margin above first line- editor.changeViewZones((accessor: any) => {+const JsonEditor = ({ value = '', readOnly = false, onInputChange = noop }: JsonEditorProps) => {+ const onMount: OnMount = (editor) => {+ editor.changeViewZones((accessor) => {accessor.addZone({afterLineNumber: 0,heightInPx: 4,@@ -36,17 +22,12 @@ const JsonEditor = ({const Loading = () => <h4>Loading</h4>- useEffect(() => {- setId(uuidv4())- }, [defaultValue])-return (<EditorclassName="monaco-editor"theme="supabase"defaultLanguage="json"- defaultValue={defaultValue}- path={queryId || id}+ value={value}loading={<Loading />}options={{readOnly,diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/JsonEditor/JsonEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/JsonEditor/JsonEditor.tsxindex 38bf50df84b..85675e617c6 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/JsonEditor/JsonEditor.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/JsonEditor/JsonEditor.tsx@@ -54,7 +54,7 @@ const JsonEdit = ({}}- function onInputChange(value: any) {+ function onInputChange(value: string | undefined) {setJsonStr(value ?? '')}@@ -102,9 +102,10 @@ const JsonEdit = ({{view === 'edit' ? (<div className="h-[500px] w-full flex-grow border dark:border-dark"><JsonEditor+ key={jsonString}readOnly={readOnly}onInputChange={onInputChange}- defaultValue={jsonStr.toString()}+ value={jsonStr.toString()}/></div>) : (