Skip to content

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

set default value if empty array (#34828)

Saxon Fletcher61a18cdcb649
diff --git a/apps/studio/components/ui/FileExplorerAndEditor/FileExplorerAndEditor.tsx b/apps/studio/components/ui/FileExplorerAndEditor/FileExplorerAndEditor.tsx
index 073a2c74bf1..d9d6f233b54 100644
--- a/apps/studio/components/ui/FileExplorerAndEditor/FileExplorerAndEditor.tsx
+++ b/apps/studio/components/ui/FileExplorerAndEditor/FileExplorerAndEditor.tsx
@@ -82,7 +82,7 @@ const FileExplorerAndEditor = ({
}
const addNewFile = () => {
- const newId = Math.max(...files.map((f) => f.id)) + 1
+ const newId = Math.max(0, ...files.map((f) => f.id)) + 1
const updatedFiles = files.map((f) => ({ ...f, selected: false }))
onFilesChange([
...updatedFiles,