: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): show formula input when toggling formula mode on (#60621)
Anders64759219c73f
diff --git a/frontend/src/queries/nodes/InsightViz/TrendsFormula.tsx b/frontend/src/queries/nodes/InsightViz/TrendsFormula.tsxindex f1e06d26ba0c..f2112f23969d 100644--- a/frontend/src/queries/nodes/InsightViz/TrendsFormula.tsx+++ b/frontend/src/queries/nodes/InsightViz/TrendsFormula.tsx@@ -21,8 +21,10 @@ export function TrendsFormula({ insightProps }: EditorFilterProps): JSX.Elementconst [localValues, setLocalValues] = useState<TrendsFormulaNode[]>(values)useEffect(() => {- // Don't clear the formulas so that the values are still there after toggling the formula switch- if (formulaNodes) {+ // Don't clear the formulas so that the values are still there after toggling the formula switch.+ // formulaNodes is [] (truthy) when no formula is set, so check length to fall through to the+ // hasFormula branch that seeds one empty input when formula mode is toggled on.+ if (formulaNodes && formulaNodes.length > 0) {setValues(formulaNodes)// Merge incoming formulas with existing local fields, maintaining ordersetLocalValues((prev) => {diff --git a/playwright/page-models/insights/trendsInsight.ts b/playwright/page-models/insights/trendsInsight.tsindex fb4140a7e382..41d8a60e87c1 100644--- a/playwright/page-models/insights/trendsInsight.ts+++ b/playwright/page-models/insights/trendsInsight.ts@@ -21,7 +21,6 @@ export class TrendsInsight extends ChartInsightBase {private readonly detailsLoader: Locatorprivate readonly addSeriesButton: Locator- private readonly addFormulaButton: Locatorconstructor(page: Page) {super(page, page.getByTestId('insights-graph'))@@ -35,7 +34,6 @@ export class TrendsInsight extends ChartInsightBase {this.breakdownButton = page.getByTestId('add-breakdown-button')this.formulaSwitch = page.locator('#trends-formula-switch')this.formulaInput = page.getByPlaceholder('Example: (A + B) / 100')- this.addFormulaButton = page.getByRole('button', { name: 'Add formula' })this.dateRangeButton = page.getByTestId('date-filter')this.chartTypeButton = page.getByTestId('chart-filter')this.comparisonButton = page.getByTestId('compare-filter')@@ -99,10 +97,10 @@ export class TrendsInsight extends ChartInsightBase {async setFormula(formula: string): Promise<void> {await this.formulaSwitch.click()- await this.addFormulaButton.click()await this.formulaInput.first().waitFor({ state: 'visible' })await this.formulaInput.first().fill(formula)await this.formulaInput.first().press('Enter')+ await this.waitForChart()}mathSelector(seriesIndex: number): Locator {