Skip to content

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

Joshen/fe 3384 prevent ai assistant chat panel from closing after query (#47951)

Joshen Lim66691ad9ce54
diff --git a/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/FloatingMobileToolbar.tsx b/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/FloatingMobileToolbar.tsx
index 30547a2ba0b..da5b728cf82 100644
--- a/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/FloatingMobileToolbar.tsx
+++ b/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/FloatingMobileToolbar.tsx
@@ -50,6 +50,7 @@ export const FloatingMobileToolbar = ({ hideMobileMenu }: { hideMobileMenu?: boo
onPointerMove={drag.handlePointerMove}
>
<div
+ id="mobile-nav-actions"
className={cn(
'flex pointer-events-auto cursor-grab active:cursor-grabbing flex-row items-center justify-between w-auto rounded-full',
'bg-overlay/80 backdrop-blur-md px-2.5 py-2 gap-2',
diff --git a/apps/studio/components/layouts/Navigation/NavigationBar/StudioMobileSheetNav.tsx b/apps/studio/components/layouts/Navigation/NavigationBar/StudioMobileSheetNav.tsx
index ad3ae93e090..ecb828944ee 100644
--- a/apps/studio/components/layouts/Navigation/NavigationBar/StudioMobileSheetNav.tsx
+++ b/apps/studio/components/layouts/Navigation/NavigationBar/StudioMobileSheetNav.tsx
@@ -1,3 +1,4 @@
+import { useBreakpoint } from 'common'
import type { ReactNode } from 'react'
import { CommandWrapper } from 'ui-patterns/CommandMenu'
import { MobileSheetNav } from 'ui-patterns/MobileSheetNav'
@@ -37,7 +38,8 @@ function getSheetChildren(
return null
}
-const StudioMobileSheetNav = () => {
+export const StudioMobileSheetNav = () => {
+ const isMobile = useBreakpoint('md')
const { content, setContent } = useMobileSheet()
const { activeSidebar } = useSidebarManagerSnapshot()
const sheetChildren = getSheetChildren(content, activeSidebar ?? null)
@@ -49,15 +51,24 @@ const StudioMobileSheetNav = () => {
}
}
+ if (!isMobile) return null
+
return (
<MobileSheetNav
open={content !== null}
onOpenChange={handleOpenChange}
shouldCloseOnViewportResize={!activeSidebar}
+ onPointerDownOutside={(event) => {
+ // Buttons in the floating toolbar (#mobile-nav-actions) render outside this sheet, so
+ // Radix treats taps on them as an outside click and closes the sheet before the button's
+ // own onClick runs. Those buttons already manage the sheet themselves, so don't let
+ // Radix's outside-dismiss pre-empt them.
+ if ((event.target as HTMLElement | null)?.closest('#mobile-nav-actions')) {
+ event.preventDefault()
+ }
+ }}
>
{sheetChildren}
</MobileSheetNav>
)
}
-
-export { StudioMobileSheetNav }
diff --git a/packages/ui-patterns/src/MobileSheetNav/MobileSheetNav.tsx b/packages/ui-patterns/src/MobileSheetNav/MobileSheetNav.tsx
index 3d29ab996f1..47ebc96ae86 100644
--- a/packages/ui-patterns/src/MobileSheetNav/MobileSheetNav.tsx
+++ b/packages/ui-patterns/src/MobileSheetNav/MobileSheetNav.tsx
@@ -1,7 +1,7 @@
'use client'
import { useRouter } from 'next/router'
-import { useEffect } from 'react'
+import { ComponentProps, useEffect } from 'react'
import { ErrorBoundary } from 'react-error-boundary'
import { useWindowSize } from 'react-use'
import { CommandEmpty, Sheet, SheetContent } from 'ui'
@@ -14,6 +14,7 @@ const MobileSheetNav: React.FC<{
className?: string
shouldCloseOnRouteChange?: boolean
shouldCloseOnViewportResize?: boolean
+ onPointerDownOutside?: ComponentProps<typeof SheetContent>['onPointerDownOutside']
}> = ({
children,
open = false,
@@ -21,6 +22,7 @@ const MobileSheetNav: React.FC<{
className,
shouldCloseOnRouteChange = true,
shouldCloseOnViewportResize = true,
+ onPointerDownOutside,
}) => {
const router = useRouter()
const { width } = useWindowSize()
@@ -48,6 +50,7 @@ const MobileSheetNav: React.FC<{
showClose={false}
size="full"
side="bottom"
+ onPointerDownOutside={onPointerDownOutside}
className={cn(
'rounded-t-lg bg-background overflow-hidden overflow-y-scroll h-[85dvh] md:max-h-[500px]',
className