Skip to content

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

Prevent autofocusing into code editor in create index side panel

Joshen Lim5d8b308a5071
diff --git a/studio/components/interfaces/Database/Indexes/CreateIndexSidePanel.tsx b/studio/components/interfaces/Database/Indexes/CreateIndexSidePanel.tsx
index 01c6a54e55e..e0a9474bb88 100644
--- a/studio/components/interfaces/Database/Indexes/CreateIndexSidePanel.tsx
+++ b/studio/components/interfaces/Database/Indexes/CreateIndexSidePanel.tsx
@@ -221,6 +221,7 @@ CREATE INDEX ON "${selectedSchema}"."${selectedEntity}" USING ${selectedIndexTyp
<div className="relative h-full">
<CodeEditor
isReadOnly
+ autofocus={false}
id={`${selectedSchema}-${selectedEntity}-${selectedColumns.join(
','
)}-${selectedIndexType}`}
diff --git a/studio/components/ui/CodeEditor/CodeEditor.tsx b/studio/components/ui/CodeEditor/CodeEditor.tsx
index 7939c7881e7..080742477c0 100644
--- a/studio/components/ui/CodeEditor/CodeEditor.tsx
+++ b/studio/components/ui/CodeEditor/CodeEditor.tsx
@@ -9,6 +9,7 @@ import { alignEditor } from './CodeEditor.utils'
interface CodeEditorProps {
id: string
language: 'pgsql' | 'json' | 'html'
+ autofocus?: boolean
defaultValue?: string
isReadOnly?: boolean
onInputChange?: (value?: string) => void
@@ -24,6 +25,7 @@ const CodeEditor = ({
id,
language,
defaultValue,
+ autofocus = true,
isReadOnly = false,
hideLineNumbers = false,
onInputChange = noop,
@@ -53,7 +55,7 @@ const CodeEditor = ({
})
await timeout(500)
- editor?.focus()
+ if (autofocus) editor?.focus()
editorRef.current = editor
}