Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

fix: broken billing page for some cases

Carl-Gerhard Lindesvärd8b110913365b
diff --git a/apps/start/src/components/organization/billing-prompt.tsx b/apps/start/src/components/organization/billing-prompt.tsx
index b08387af8..92a6db788 100644
--- a/apps/start/src/components/organization/billing-prompt.tsx
+++ b/apps/start/src/components/organization/billing-prompt.tsx
@@ -170,8 +170,18 @@ export default function BillingPrompt({
}
if (!(bestProductFit && bestPrice && price)) {
+ // While products load we don't yet know if a plan fits. Render a plain
+ // loading button here — `asChild` + `loading` can't coexist because the
+ // spinner would give Radix's <Slot> a second child (React.Children.only).
+ if (isLoadingProducts) {
+ return (
+ <Button className="w-full" loading size="lg">
+ Loading plans
+ </Button>
+ );
+ }
return (
- <Button asChild className="w-full" loading={isLoadingProducts} size="lg">
+ <Button asChild className="w-full" size="lg">
<a href="mailto:[email protected]?subject=Custom plan">
Get a custom plan
</a>
diff --git a/apps/start/src/components/ui/button.tsx b/apps/start/src/components/ui/button.tsx
index 248770ed6..cdb1fc67a 100644
--- a/apps/start/src/components/ui/button.tsx
+++ b/apps/start/src/components/ui/button.tsx
@@ -98,6 +98,28 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
// Determine spinner size based on button size
const spinnerSize = size === 'lg' ? 'md' : size === 'icon' ? 'sm' : 'sm';
+ // With `asChild`, Radix's <Slot> merges props onto a single child element
+ // and calls React.Children.only. Injecting a spinner/icon as extra siblings
+ // would crash ("expected to receive a single React element child"), so the
+ // asChild path forwards only the child and skips those adornments.
+ if (asChild) {
+ return (
+ <Comp
+ className={cn(
+ buttonVariants({ variant, size, className }),
+ fixHeight({ autoHeight, size }),
+ loadingAbsolute && 'relative'
+ )}
+ disabled={loading || disabled}
+ ref={ref}
+ type={type}
+ {...props}
+ >
+ {children}
+ </Comp>
+ );
+ }
+
return (
<Comp
className={cn(