Skip to content

Commit 205a8bd

Browse files
authored
Project dropdown fix staying on current page for selected project in onSelect (supabase#38957)
1 parent 84cf676 commit 205a8bd

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ export const ProjectDropdown = () => {
7373
setOpen={setOpen}
7474
selectedRef={ref}
7575
onSelect={(project) => {
76-
router.push(`/project/${project.ref}`)
76+
const sanitizedRoute = sanitizeRoute(router.route, router.query)
77+
const href = sanitizedRoute?.replace('[ref]', project.ref) ?? `/project/${project.ref}`
78+
router.push(href)
7779
}}
7880
renderTrigger={() => (
7981
<Button
@@ -87,11 +89,14 @@ export const ProjectDropdown = () => {
8789
// [Joshen] Temp while we're interim between v1 and v2 billing
8890
const sanitizedRoute = sanitizeRoute(router.route, router.query)
8991
const href = sanitizedRoute?.replace('[ref]', project.ref) ?? `/project/${project.ref}`
92+
const isSelected = project.ref === ref
9093

9194
return (
9295
<Link href={href} className="w-full flex items-center justify-between">
93-
{project.name}
94-
{project.ref === ref && <Check size={16} />}
96+
<span className={cn('truncate', isSelected ? 'max-w-60' : 'max-w-64')}>
97+
{project.name}
98+
</span>
99+
{isSelected && <Check size={16} />}
95100
</Link>
96101
)
97102
}}

0 commit comments

Comments
 (0)