: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(insights): fill the date variable popover with the calendar (#81042)
Paul D'Ambra7bd719d11c57
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex b947a2764791..262d58bd3afa 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -3081,9 +3081,13 @@ snapshots:insights-trendsslopechart--with-legend--light:hash: v1.k794b7964.741230bf1c62eef2ad168576820c7b32c4d625c3930fed4a8290b64c89995acf.5S1wF2zrE9wuSnvvi_K2ke3N3ZDxGHbaXmhhKzO5NX4insights-variables--date-variable-input--dark:- hash: v1.k794b7964.9f55263cf42996613af3d9a4e643fd80f6cc106a45365d2dd4e271894850e217.v6mqgP6NMvMvOWrF2XuxcO5OS03GKEoGV9wMH6hRZ4o+ hash: v1.k794b7964.fbfdd1ab9877182aad54b9e982528eefa2e6fcaa46dd3f456fb09008c8c75fd7.2UHdBAKQYuxX4igfiTSsjJsXkU4F-RYTg08z-HdCyksinsights-variables--date-variable-input--light:- hash: v1.k794b7964.c1777f08d6a5dfa0dd5c18d3e4a0721c6f68e0b5e83850a01ffa549f5232fe0e.qTeNMD1AqBtCmBYDTSU2gjHY1kGCeXFPp0s7WhTrxgA+ hash: v1.k794b7964.7d12e17009d1b61a69effad186e8ec6e543a4b35cf5a4dc28db076b947730a3b.6oJL6fvz-xFkp8cLiQhoN6_x5stTKMR3LFFv7Ag3nHw+ insights-variables--date-variable-input-with-long-code-name--dark:+ hash: v1.k794b7964.aa04b3084acd359081e1e092f8431bd4d48693f94ce0c2f36fc806113ce8a08f.eP9h3WgMVuGCUSzNkq4BxnskE8uW2GBLHNV_mb9Bz3c+ insights-variables--date-variable-input-with-long-code-name--light:+ hash: v1.k794b7964.f5568aae8786ef8ca0e998ac32fea8be5fddf4559ee00bf19cec72be78f10c0d.QxzRYYbgDUBH3s4E5FK1lQZdsJi1AMjjsZQKpfKPtYwinsights-variables--relative-date-variable-input--dark:hash: v1.k794b7964.993cb47aaab3f9408430d0dcdda87e8eca9cb16c7681dcde25e58a4611f64828.c_7HSBE3vhm-UjRbxmi5mdL2bQKskYYJfcxIP1-a-Pwinsights-variables--relative-date-variable-input--light:diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Variables/VariableFields.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Variables/VariableFields.tsxindex f95e66257865..a83ce7aed563 100644--- a/frontend/src/queries/nodes/DataVisualization/Components/Variables/VariableFields.tsx+++ b/frontend/src/queries/nodes/DataVisualization/Components/Variables/VariableFields.tsx@@ -13,6 +13,7 @@ import { dayjs } from 'lib/dayjs'import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'import { LemonField } from 'lib/lemon-ui/LemonField'import { CodeEditorResizeable } from 'lib/monaco/CodeEditorResizable'+import { cn } from 'lib/utils/css-classes'import {POSTHOG_WAREHOUSE,connectionSelectorLogic,@@ -356,15 +357,17 @@ export const DateField = ({variable,updateVariable,onApply,+ className,}: DirectFieldProps<DateVariable> & {/** Called when the calendar's own Apply button is pressed, so a caller can treat it as the commit. */onApply?: (value: string) => void+ className?: string}): JSX.Element => {const isRelative = isRelativeDateValue(variable.default_value)const relativeValue = parseRelativeDateValue(variable.default_value) ?? { amount: 0, unit: 'd' as RelativeDateUnit }return (- <div className="flex flex-col gap-2">+ <div className={cn('flex flex-col gap-2', className)}><LemonSegmentedButtonclassName="w-full"value={isRelative ? 'relative' : 'fixed'}diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Variables/Variables.stories.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Variables/Variables.stories.tsxindex 48ba90d01fc2..2457a80d48d3 100644--- a/frontend/src/queries/nodes/DataVisualization/Components/Variables/Variables.stories.tsx+++ b/frontend/src/queries/nodes/DataVisualization/Components/Variables/Variables.stories.tsx@@ -52,3 +52,12 @@ export const DateVariableInput: Story = {export const RelativeDateVariableInput: Story = {args: { variable: { ...dateVariable, default_value: '-7d' } },}++/** The editing UI shows the variable's HogQL reference on one unbroken line, so a long code name+ * widens the popover well past its usual 320px. Guards against the calendar growing with it. */+export const DateVariableInputWithLongCodeName: Story = {+ args: {+ showEditingUI: true,+ variable: { ...dateVariable, code_name: 'quarterly_revenue_report_period_start_date' },+ },+}diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Variables/Variables.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Variables/Variables.tsxindex d3112eab93df..4059cf82104e 100644--- a/frontend/src/queries/nodes/DataVisualization/Components/Variables/Variables.tsx+++ b/frontend/src/queries/nodes/DataVisualization/Components/Variables/Variables.tsx@@ -214,6 +214,9 @@ export const VariableInput = ({)}{variable.type === 'Date' && (<DateField+ // The calendar is narrower than the popover, so grow to fill it rather than+ // leaving dead space down the right-hand side.+ className="grow"variable={{ ...variable, default_value: String(localInputValue) } as DateVariable}updateVariable={(updatedVariable) => setLocalInputValue(updatedVariable.default_value)}onApply={commit}@@ -236,7 +239,9 @@ export const VariableInput = ({<><LemonDivider className="m1" />- <div className="flex p-1">+ {/* Sized off the popover rather than its own content, so a long variable+ reference wraps instead of stretching the field above it. */}+ <div className="flex p-1 w-0 min-w-full"><coderef={codeRef}onClick={() => {@@ -251,7 +256,9 @@ export const VariableInput = ({}}}}- className="text-xs flex flex-1 items-center mr-2"+ // The reference is one unbreakable token, so without this a long code+ // name widens the whole popover instead of wrapping.+ className="text-xs flex flex-1 items-center mr-2 min-w-0 break-all">{variableAsHogQL}</code>