The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Button to add preventDefault onClick if disabled (#37784)
Joshen Limf927998e4e83
diff --git a/packages/ui/src/components/Button/Button.tsx b/packages/ui/src/components/Button/Button.tsxindex 20513b69d48..df718855739 100644--- a/packages/ui/src/components/Button/Button.tsx+++ b/packages/ui/src/components/Button/Button.tsx@@ -6,7 +6,6 @@ import { Loader2 } from 'lucide-react'import { cloneElement, forwardRef, isValidElement } from 'react'import { SIZE_VARIANTS, SIZE_VARIANTS_DEFAULT } from '../../lib/constants'import { cn } from '../../lib/utils/cn'-import { IconContext } from '../Icon/IconContext'export type ButtonVariantProps = VariantProps<typeof buttonVariants>const buttonVariants = cva(@@ -255,6 +254,11 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>({...props}disabled={disabled}className={cn(buttonVariants({ type, size, disabled, block, rounded }), className)}+ onClick={(e) => {+ // [Joshen] Prevents redirecting if Button is used with a link-based child element+ if (disabled) return e.preventDefault()+ else props?.onClick?.(e)+ }}>{asChild ? (isValidElement(children) ? (