:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(ui): open disabled reason tooltips on click (#89888)
Eleftheria Trivyzakie3540bb9fa12
diff --git a/frontend/src/lib/components/Account/ProjectCombobox.tsx b/frontend/src/lib/components/Account/ProjectCombobox.tsxindex 45960b75b175..bb3ffa9abec3 100644--- a/frontend/src/lib/components/Account/ProjectCombobox.tsx+++ b/frontend/src/lib/components/Account/ProjectCombobox.tsx@@ -191,7 +191,9 @@ export function ProjectCombobox(): JSX.Element | null {tooltip="Create a new project"tooltipPlacement="right"className="shrink-0"- disabled={!!projectCreationForbiddenReason}+ disabledReasons={+ projectCreationForbiddenReason ? { [projectCreationForbiddenReason]: true } : undefined+ }><IconPlusSmall className="text-tertiary" />New projectdiff --git a/frontend/src/lib/lemon-ui/LemonButton/LemonButton.tsx b/frontend/src/lib/lemon-ui/LemonButton/LemonButton.tsxindex dd9d30a80c2c..f80dc212edbd 100644--- a/frontend/src/lib/lemon-ui/LemonButton/LemonButton.tsx+++ b/frontend/src/lib/lemon-ui/LemonButton/LemonButton.tsx@@ -301,6 +301,8 @@ export const LemonButton: React.FunctionComponent<LemonButtonProps & React.RefAtarrowOffset={tooltipArrowOffset}docLink={tooltipDocLink}visible={tooltipForceMount}+ // A click on a blocked button must surface the reason, since hover is unavailable on touch+ openOnClick={!!disabledReason}interactive={disabledReasonInteractive}closeDelayMs={disabledReasonInteractive ? INTERACTIVE_CLOSE_DELAY_MS : undefined}>diff --git a/frontend/src/lib/ui/Button/ButtonPrimitives.tsx b/frontend/src/lib/ui/Button/ButtonPrimitives.tsxindex 0967a648818b..d57284d26620 100644--- a/frontend/src/lib/ui/Button/ButtonPrimitives.tsx+++ b/frontend/src/lib/ui/Button/ButtonPrimitives.tsx@@ -292,6 +292,11 @@ export const ButtonPrimitive = forwardRef<HTMLButtonElement, ButtonPrimitivePropconst effectiveVariant = forceVariant ? variant : context?.variantContext || variantlet effectiveDisabled = disabledReasons ? Object.values(disabledReasons).some((value) => value) : disabledconst externalAriaDisabled = rest['aria-disabled']++ // If there are disabled reasons which are true, render them, otherwise render the tooltip+ const tooltipTitle = disabledReasons && effectiveDisabled ? renderDisabledReasons(disabledReasons) : tooltip+ const hasTooltip = !!(tooltipTitle || tooltipDocLink)+let buttonComponent: JSX.Element = React.createElement('button',{@@ -309,7 +314,9 @@ export const ButtonPrimitive = forwardRef<HTMLButtonElement, ButtonPrimitivePropinert,truncate,className,- })+ }),+ // A disabled button swallows pointer events, so let the tooltip wrapper span receive them+ hasTooltip && effectiveDisabled && 'pointer-events-none'),ref,disabled: effectiveDisabled,@@ -323,13 +330,7 @@ export const ButtonPrimitive = forwardRef<HTMLButtonElement, ButtonPrimitivePropchildren)- // If there are disabled reasons which are true, render them, otherwise render the tooltip- const tooltipTitle =- disabledReasons && Object.values(disabledReasons).some(Boolean)- ? renderDisabledReasons(disabledReasons)- : tooltip-- if (tooltipTitle || tooltipDocLink) {+ if (hasTooltip) {const tooltipChild = effectiveDisabled ? (<span className="inline-flex w-fit">{buttonComponent}</span>) : (@@ -344,6 +345,7 @@ export const ButtonPrimitive = forwardRef<HTMLButtonElement, ButtonPrimitivePropdocLink={tooltipDocLink}visible={tooltipVisible}interactive={tooltipInteractive}+ openOnClick={!!effectiveDisabled}>{tooltipChild}</Tooltip>