Skip to content

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

Project dropdown fix staying on current page for selected project in onSelect (#38957)

Joshen Lim205a8bd14d46
diff --git a/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx b/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx
index de923374f34..542053c815b 100644
--- a/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx
+++ b/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx
@@ -73,7 +73,9 @@ export const ProjectDropdown = () => {
setOpen={setOpen}
selectedRef={ref}
onSelect={(project) => {
- router.push(`/project/${project.ref}`)
+ const sanitizedRoute = sanitizeRoute(router.route, router.query)
+ const href = sanitizedRoute?.replace('[ref]', project.ref) ?? `/project/${project.ref}`
+ router.push(href)
}}
renderTrigger={() => (
<Button
@@ -87,11 +89,14 @@ export const ProjectDropdown = () => {
// [Joshen] Temp while we're interim between v1 and v2 billing
const sanitizedRoute = sanitizeRoute(router.route, router.query)
const href = sanitizedRoute?.replace('[ref]', project.ref) ?? `/project/${project.ref}`
+ const isSelected = project.ref === ref
return (
<Link href={href} className="w-full flex items-center justify-between">
- {project.name}
- {project.ref === ref && <Check size={16} />}
+ <span className={cn('truncate', isSelected ? 'max-w-60' : 'max-w-64')}>
+ {project.name}
+ </span>
+ {isSelected && <Check size={16} />}
</Link>
)
}}