Skip to content

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

fix(cmdk): empty state shows up when it shouldn't (#29272)

Charisf6768edde71c
diff --git a/apps/studio/components/interfaces/BranchManagement/Branch.Commands.tsx b/apps/studio/components/interfaces/BranchManagement/Branch.Commands.tsx
index 6979b223324..40a6f0b94cc 100644
--- a/apps/studio/components/interfaces/BranchManagement/Branch.Commands.tsx
+++ b/apps/studio/components/interfaces/BranchManagement/Branch.Commands.tsx
@@ -17,7 +17,7 @@ export function useBranchCommands() {
let { data: branches } = useBranchesQuery(
{
- projectRef: selectedProject?.ref,
+ projectRef: selectedProject?.parentRef,
},
{ enabled: isBranchingEnabled }
)
diff --git a/packages/ui-patterns/CommandMenu/internal/CommandEmpty.tsx b/packages/ui-patterns/CommandMenu/internal/CommandEmpty.tsx
index 2128bbba340..0a98790ac60 100644
--- a/packages/ui-patterns/CommandMenu/internal/CommandEmpty.tsx
+++ b/packages/ui-patterns/CommandMenu/internal/CommandEmpty.tsx
@@ -1,6 +1,6 @@
'use client'
-import { type PropsWithChildren, type RefObject, useMemo, useState } from 'react'
+import { type PropsWithChildren, type RefObject, useEffect, useState } from 'react'
import { cn } from 'ui'
@@ -24,14 +24,9 @@ const CommandEmpty = ({
const query = useQuery()
const [render, setRender] = useState(false)
- useMemo(() => {
- if (!query) setRender(false)
- /**
- * In a timeout so the DOM update happens before we query.
- */
- setTimeout(() => {
- setRender(!listRef?.current?.querySelector('[cmdk-item]'))
- })
+ useEffect(() => {
+ if (!query) return setRender(false)
+ setRender(!listRef?.current?.querySelector('[cmdk-item]'))
}, [query])
return (