The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: middle click, ctrl+click to open new tab for edge functions (#41376)
Ali Waseem1df47957c2bb
diff --git a/apps/studio/components/interfaces/Functions/EdgeFunctionsListItem.tsx b/apps/studio/components/interfaces/Functions/EdgeFunctionsListItem.tsxindex b66c7f8d6be..d3407ba1e32 100644--- a/apps/studio/components/interfaces/Functions/EdgeFunctionsListItem.tsx+++ b/apps/studio/components/interfaces/Functions/EdgeFunctionsListItem.tsx@@ -9,6 +9,7 @@ import { useCustomDomainsQuery } from 'data/custom-domains/custom-domains-query'import type { EdgeFunctionsResponse } from 'data/edge-functions/edge-functions-query'import { copyToClipboard, TableCell, TableRow } from 'ui'import { TimestampInfo } from 'ui-patterns'+import { createNavigationHandler } from 'lib/navigation'interface EdgeFunctionsListItemProps {function: EdgeFunctionsResponse@@ -29,13 +30,16 @@ export const EdgeFunctionsListItem = ({ function: item }: EdgeFunctionsListItemP? `https://${customDomainData.customDomain.hostname}/functions/v1/${item.slug}`: `${protocol}://${endpoint}/functions/v1/${item.slug}`+ const handleNavigation = createNavigationHandler(`/project/${ref}/functions/${item.slug}`, router)+return (<TableRowkey={item.id}- onClick={() => {- router.push(`/project/${ref}/functions/${item.slug}`)- }}- className="cursor-pointer"+ onClick={handleNavigation}+ onAuxClick={handleNavigation}+ onKeyDown={handleNavigation}+ tabIndex={0}+ className="cursor-pointer inset-focus"><TableCell><p className="text-sm text-foreground whitespace-nowrap py-2">{item.name}</p>@@ -86,6 +90,9 @@ export const EdgeFunctionsListItem = ({ function: item }: EdgeFunctionsListItemP</TableCell><TableCell className="lg:table-cell"><p className="text-foreground-light">{item.version}</p>+ <button tabIndex={-1} className="sr-only">+ Go to function details+ </button></TableCell></TableRow>)diff --git a/apps/studio/components/interfaces/Storage/FilesBuckets/BucketTable.tsx b/apps/studio/components/interfaces/Storage/FilesBuckets/BucketTable.tsxindex c67793c2272..e399b925e4a 100644--- a/apps/studio/components/interfaces/Storage/FilesBuckets/BucketTable.tsx+++ b/apps/studio/components/interfaces/Storage/FilesBuckets/BucketTable.tsx@@ -7,11 +7,10 @@ import {} from 'components/ui/VirtualizedTable'import { Bucket } from 'data/storage/buckets-query'import { FilesBucket as FilesBucketIcon } from 'icons'-import { BASE_PATH } from 'lib/constants'import { formatBytes } from 'lib/helpers'+import { createNavigationHandler } from 'lib/navigation'import { ChevronRight } from 'lucide-react'import { useRouter } from 'next/navigation'-import type React from 'react'import { Badge, TableCell, TableHead, TableHeader, TableRow } from 'ui'type BucketTableMode = 'standard' | 'virtualized'@@ -88,30 +87,19 @@ export const BucketTableRow = ({const BucketTableRow = mode === 'standard' ? TableRow : VirtualizedTableRowconst BucketTableCell = mode === 'standard' ? TableCell : VirtualizedTableCell- const handleBucketNavigation = (- bucketId: string,- event: React.MouseEvent | React.KeyboardEvent- ) => {- const url = `/project/${projectRef}/storage/files/buckets/${encodeURIComponent(bucketId)}`- if (event.metaKey || event.ctrlKey) {- window.open(`${BASE_PATH}${url}`, '_blank')- } else {- router.push(url)- }- }+ const handleBucketNavigation = createNavigationHandler(+ `/project/${projectRef}/storage/files/buckets/${encodeURIComponent(bucket.id)}`,+ router+ )return (<BucketTableRowkey={bucket.id}data-bucket-id={bucket.id}className="relative cursor-pointer h-16 group inset-focus"- onClick={(event) => handleBucketNavigation(bucket.id, event)}- onKeyDown={(event) => {- if (event.key === 'Enter' || event.key === ' ') {- event.preventDefault()- handleBucketNavigation(bucket.id, event)- }- }}+ onClick={handleBucketNavigation}+ onAuxClick={handleBucketNavigation}+ onKeyDown={handleBucketNavigation}tabIndex={0}><BucketTableCell className="w-2 pr-1">diff --git a/apps/studio/lib/navigation.ts b/apps/studio/lib/navigation.tsnew file mode 100644index 00000000000..f02abe537f4--- /dev/null+++ b/apps/studio/lib/navigation.ts@@ -0,0 +1,72 @@+import type { NextRouter } from 'next/router'+import { BASE_PATH } from './constants'+import { useRouter } from 'next/navigation'++type Router = NextRouter | ReturnType<typeof useRouter>++const MIDDLE_MOUSE_BUTTON = 1++/**+ * Creates a navigation handler that supports keyboard, modifier clicks, and middle mouse button.+ *+ * This is a curried function that takes a URL and router, and returns an event handler that:+ * - Handles keyboard navigation (Enter/Space keys)+ * - Opens in new tab on Cmd/Ctrl + click+ * - Opens in new tab on middle mouse button click+ * - Performs normal navigation on regular click+ *+ * @param url - The relative URL to navigate to (e.g., "/project/123/functions/my-function")+ * @param router - Next.js router instance (supports both Pages Router and App Router)+ * @returns Event handler function for onClick, onAuxClick, and onKeyDown+ *+ * @example+ * ```tsx+ * const router = useRouter()+ * const handleNavigation = createNavigationHandler(`/project/${ref}/functions/${slug}`, router)+ *+ * <TableRow+ * onClick={handleNavigation}+ * onAuxClick={handleNavigation}+ * onKeyDown={handleNavigation}+ * tabIndex={0}+ * />+ * ```+ */+export const createNavigationHandler = (url: string, router: Router) => {+ return (event: React.MouseEvent | React.KeyboardEvent) => {+ // Handle keyboard events+ if ('key' in event) {+ if (event.key === 'Enter' || event.key === ' ') {+ event.preventDefault()++ const isModifierKey = event.metaKey || event.ctrlKey+ if (isModifierKey) {+ window.open(`${BASE_PATH}${url}`, '_blank')+ } else {+ router.push(url)+ }+ }+ return+ }++ // Handle Cmd/Ctrl + left click (modifier click)+ const isModifierClick =+ 'button' in event && event.button === 0 && (event.metaKey || event.ctrlKey)+ if (isModifierClick) {+ event.preventDefault()+ window.open(`${BASE_PATH}${url}`, '_blank')+ return+ }++ // Handle middle mouse button click+ const isMiddleClick = 'button' in event && event.button === MIDDLE_MOUSE_BUTTON+ if (isMiddleClick) {+ event.preventDefault()+ window.open(`${BASE_PATH}${url}`, '_blank')+ return+ }++ // Handle regular left click+ router.push(url)+ }+}