Skip to content

: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.

fix(workflows): keep the graph visible with sidebars open (#104984)

Daniel Marchuk9e9f43a684fd
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 0e94ef17452d..7823da917a0d 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6976,6 +6976,10 @@ snapshots:
hash: v1.k794b7964.9c165882088a94a60c3f278c5ac933e19deea0799e2f178773b9562a06d5b587.T17LeudaJGjY7lpzSaWm3Vstubn72J6YmRirV14ZZGQ
products-workflows-editor-graph--customer-onboarding-and-retention--light:
hash: v1.k794b7964.d1a0262e3ba550f69a2ab3d0bcda4327157eb1f947c5ad35cb2267ba70cbdec8.2bL0CCEt9WyVdRlAp8Lyr03y_DB6ERgysK-0eIDqO1E
+ products-workflows-editor-graph--narrow-workflow--dark:
+ hash: v1.k794b7964.01f65c99f249253da38e1b14144997481107c43fd970d9ffb0325706c903902c.C8EF2O1y8NSkFVFK2fakvB6yqqMeMB6kaqHVJRLC2ZI
+ products-workflows-editor-graph--narrow-workflow--light:
+ hash: v1.k794b7964.123ec2fa1f1ba91cbf8257978a890c2cf9223d0fcef1c9a37c6fd7b594e945c3.Q0Btzh2-Lg299AqvrCAPrc4Bgy2OFM_gTWDFODs37RM
products-workflows-editor-graph--new-workflow--dark:
hash: v1.k794b7964.7ba2d7e983927e8e8375e47d0c949b93943fd66aae376f98e125d683dd4ffd99.YZb3PzvlCIEGiDRA-lVQffhm1K7TV_CXi-VCWJpzbLc
products-workflows-editor-graph--new-workflow--light:
@@ -6992,6 +6996,10 @@ snapshots:
hash: v1.k794b7964.7c60c3d139d5b5dabbd7fb974f621f135149176f1c86184aed079c6deaef414e.AkijMDM4cBxIWBu4E8V7VThp1fwVqHJcfVB24fcGK0Y
products-workflows-editor-graph--support-sla-routing--light:
hash: v1.k794b7964.185cabd282f05ff0599ff324858eeeb5a81eeeb8fffd0b072ca9d5c0d7807243.YHPb3_b2-Ub_stRNprVNr30-LC_kXEkREvdFFEMknkw
+ products-workflows-editor-graph--with-navigation--dark:
+ hash: v1.k794b7964.41531f0e4a9cb728232b50eb53a6615cbf117ec55824bccc6e42dca1c0f03d81.imMllz-NkrBb2FZ2YCA5vn3lmY8D5b933oS2mF0itww
+ products-workflows-editor-graph--with-navigation--light:
+ hash: v1.k794b7964.6d17dbab3ca3a7422ddcc58effbf489d7191bb9ef15db2d65fa405e27922a921.AsAyuHILJW39r69f-JHKnQKnqm1T5kf66hr2CkX-QNo
products-workflows-editor-tree--add-on-promotion-emails--dark:
hash: v1.k794b7964.f28f743921b108a3d7ce5c5f7f373407609e4f131790261d27afd7107909381f.Ji6HKS277Nou8dc2Ow4IG0TDdXKMQOCiNg6StWNB1Kc
products-workflows-editor-tree--add-on-promotion-emails--light:
diff --git a/products/workflows/frontend/Workflows/hogflows/HogFlowEditor.tsx b/products/workflows/frontend/Workflows/hogflows/HogFlowEditor.tsx
index ca8be8c0972b..204d53789097 100644
--- a/products/workflows/frontend/Workflows/hogflows/HogFlowEditor.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/HogFlowEditor.tsx
@@ -60,9 +60,13 @@ function HogFlowGraphEditor(): JSX.Element {
}, [setReactFlowWrapper])
useEffect(() => {
- if (nodesInitialized) {
- fitView({ duration: 0 })
+ if (!nodesInitialized || !reactFlowWrapper.current) {
+ return
}
+
+ const observer = new ResizeObserver(() => fitView({ duration: 0 }))
+ observer.observe(reactFlowWrapper.current)
+ return () => observer.disconnect()
}, [fitView, nodesInitialized])
// ReactFlow diffs its nodes prop by reference: an inline spread would hand it a fresh array
@@ -74,11 +78,13 @@ function HogFlowGraphEditor(): JSX.Element {
return (
<div
- ref={reactFlowWrapper}
- className="relative flex min-h-0 flex-1 overflow-hidden"
+ className="relative flex min-h-0 min-w-0 flex-1 overflow-hidden @max-[48rem]/workflow-editor:flex-col @max-[48rem]/workflow-editor:overflow-y-auto"
data-attr="workflow-editor"
>
- <div className="flex min-h-0 min-w-0 grow">
+ <div
+ ref={reactFlowWrapper}
+ className="flex min-h-0 min-w-0 grow @max-[48rem]/workflow-editor:min-h-80 @max-[48rem]/workflow-editor:shrink-0"
+ >
<ReactFlow<HogFlowActionNode, HogFlowActionEdge>
className="grow"
fitView
@@ -110,7 +116,7 @@ function HogFlowGraphEditor(): JSX.Element {
{(isMovingNode || isCopyingNode) && (
<Panel position="bottom-left">
{/* Offset right of the zoom controls so the hint sits beside them */}
- <div className="flex items-center gap-1.5 ml-12 px-3 py-1.5 rounded border shadow-sm bg-surface-primary text-sm">
+ <div className="flex flex-wrap items-center gap-1.5 ml-12 px-3 py-1.5 rounded border shadow-sm bg-surface-primary text-sm">
<IconInfo className="text-base text-muted shrink-0" />
<span>Click a highlighted spot to {isMovingNode ? 'move' : 'copy'} this step</span>
<span className="text-muted">· press Esc to cancel</span>
@@ -130,7 +136,7 @@ function HogFlowGraphEditor(): JSX.Element {
function HogFlowTreeEditorContent(): JSX.Element {
return (
<div
- className="relative flex min-h-0 flex-1 overflow-hidden @max-[48rem]/workflow-editor:flex-col @max-[48rem]/workflow-editor:overflow-y-auto"
+ className="relative flex min-h-0 min-w-0 flex-1 overflow-hidden @max-[48rem]/workflow-editor:flex-col @max-[48rem]/workflow-editor:overflow-y-auto"
data-attr="workflow-editor"
>
<HogFlowTreeEditor />
@@ -144,7 +150,7 @@ export function HogFlowEditor({ isTreeView }: { isTreeView: boolean }): JSX.Elem
return (
<BindLogic logic={hogFlowEditorLogic} props={logicProps}>
<HogFlowBranchSelectionProvider>
- <div className="@container/workflow-editor flex min-h-0 flex-1">
+ <div className="@container/workflow-editor flex min-h-0 min-w-0 flex-1">
{isTreeView ? (
<ReactFlowProvider>
<HogFlowTreeEditorContent />
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/graph/HogFlowGraphEditor.stories.tsx b/products/workflows/frontend/Workflows/hogflows/editor/graph/HogFlowGraphEditor.stories.tsx
index 38e8e24c4b3c..c0cb95c31579 100644
--- a/products/workflows/frontend/Workflows/hogflows/editor/graph/HogFlowGraphEditor.stories.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/editor/graph/HogFlowGraphEditor.stories.tsx
@@ -3,6 +3,10 @@ import { BindLogic, useValues } from 'kea'
import { SpinnerOverlay } from '@posthog/lemon-ui'
+import { FEATURE_FLAGS } from 'lib/constants'
+import { App } from 'scenes/App'
+import { urls } from 'scenes/urls'
+
import { workflowLogic } from '../../../workflowLogic'
import { HogFlowEditor } from '../../HogFlowEditor'
import {
@@ -25,9 +29,9 @@ const meta: Meta<typeof HogFlowEditor> = {
}
export default meta
-const WorkflowStory = ({ id }: { id: string }): JSX.Element => (
+const WorkflowStory = ({ id, className = '' }: { id: string; className?: string }): JSX.Element => (
<BindLogic logic={workflowLogic} props={{ id }}>
- <div className="h-screen [&>div]:!h-full [&>div]:!max-h-none">
+ <div className={`h-screen [&>div]:!h-full [&>div]:!max-h-none ${className}`}>
<StorybookWorkflow />
</div>
</BindLogic>
@@ -51,3 +55,21 @@ export const SupportSlaRouting: StoryFn = () => <WorkflowStory id="example-suppo
export const RenewalWindowAlerts: StoryFn = () => <WorkflowStory id="example-renewal-window-alerts" />
export const PendingTicketCleanup: StoryFn = () => <WorkflowStory id="example-pending-ticket-cleanup" />
export const AddOnPromotionEmails: StoryFn = () => <WorkflowStory id="example-add-on-promotion-emails" />
+
+// 32rem sits below the 48rem container-query breakpoint the editor uses to stack the settings
+// panel under the graph, so this story exercises the narrow layout.
+export const NarrowWorkflow: StoryFn = () => (
+ <WorkflowStory id={CUSTOMER_ONBOARDING_AND_RETENTION_WORKFLOW_ID} className="w-[32rem] max-w-full" />
+)
+NarrowWorkflow.parameters = { testOptions: { waitForSelector: '.react-flow__node' } }
+export const WithNavigation: StoryFn = () => <App />
+WithNavigation.parameters = {
+ pageUrl: `${urls.workflow(CUSTOMER_ONBOARDING_AND_RETENTION_WORKFLOW_ID, 'workflow')}?view=graph`,
+ featureFlags: [FEATURE_FLAGS.WORKFLOWS_LINEAR_VIEW],
+ mockDate: '2026-09-04 12:00:00',
+ testOptions: {
+ waitForSelector: '.react-flow__node',
+ viewport: { width: 1280, height: 900 },
+ includeNavigationInSnapshot: true,
+ },
+}
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/workflowEditorStoryFixtures.ts b/products/workflows/frontend/Workflows/hogflows/editor/workflowEditorStoryFixtures.ts
index 6f4970bf31c6..480010451840 100644
--- a/products/workflows/frontend/Workflows/hogflows/editor/workflowEditorStoryFixtures.ts
+++ b/products/workflows/frontend/Workflows/hogflows/editor/workflowEditorStoryFixtures.ts
@@ -279,6 +279,7 @@ const PICKABLE_WORKFLOWS: Record<string, HogFlow> = {
export const workflowEditorStoryDecorator = mswDecorator({
get: {
+ '/api/projects/:team_id/hog_flow_templates/': { count: 0, results: [] },
// nosemgrep: no-environments-api-urls-frontend -- api.hogFlows has not migrated to generated project routes.
'/api/environments/:team_id/hog_flows/:id/': ({ params }) => [
200,
diff --git a/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx b/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx
index e135de1e054e..4b2b1dbd4f0b 100644
--- a/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx
@@ -2887,7 +2887,13 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
}
// Get the width of the wrapper
const wrapperWidth = reactFlowWrapper.current.getBoundingClientRect()?.width ?? 0
- const panelWidth = Math.min(values.panelWidth ?? HOG_FLOW_EDITOR_DEFAULT_PANEL_WIDTH, wrapperWidth)
+ const panel = reactFlowWrapper.current.parentElement?.querySelector<HTMLElement>(
+ '[data-attr="workflow-editor-panel"]'
+ )
+ const panelWidth =
+ panel && getComputedStyle(panel).position === 'absolute'
+ ? Math.min(panel.getBoundingClientRect().width, wrapperWidth)
+ : 0
// Get the width of the thing we are going to fit to the view
const nodesWidth =
reactFlowInstance.getNodesBounds(values.selectedNode ? [values.selectedNode] : values.nodes)
@@ -2899,9 +2905,7 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
const paddingRight = wrapperWidth - nodesWidthAdjusted / 2 - (wrapperWidth - panelWidth) / 2
reactFlowInstance.fitView({
- padding: {
- right: `${paddingRight}px`,
- },
+ padding: panelWidth > 0 ? { right: `${paddingRight}px` } : 0.2,
maxZoom: noZoom ? reactFlowInstance.getZoom() : undefined,
minZoom: noZoom ? reactFlowInstance.getZoom() : undefined,
nodes: values.selectedNode ? [values.selectedNode] : values.nodes,
diff --git a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.tsx b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.tsx
index e9a1ccf3c2d8..f67419e33ae9 100644
--- a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.tsx
@@ -62,11 +62,12 @@ export function HogFlowEditorPanel({
return (
<div
ref={panelRef}
+ data-attr="workflow-editor-panel"
className={clsx(
- 'flex min-h-0 max-h-full flex-col justify-end overflow-hidden',
+ 'flex min-h-0 max-h-full flex-col justify-end overflow-hidden @max-[48rem]/workflow-editor:!relative @max-[48rem]/workflow-editor:!h-96 @max-[48rem]/workflow-editor:!min-w-0 @max-[48rem]/workflow-editor:!w-full @max-[48rem]/workflow-editor:!max-w-full @max-[48rem]/workflow-editor:shrink-0',
layout === 'floating'
? 'absolute right-0 max-w-full p-2'
- : 'relative h-full shrink-0 bg-surface-primary @max-[48rem]/workflow-editor:!h-96 @max-[48rem]/workflow-editor:!min-w-0 @max-[48rem]/workflow-editor:!w-full @max-[48rem]/workflow-editor:!max-w-full @max-[48rem]/workflow-editor:border-t'
+ : 'relative h-full shrink-0 bg-surface-primary @max-[48rem]/workflow-editor:border-t'
)}
style={
layout === 'floating'
@@ -89,7 +90,7 @@ export function HogFlowEditorPanel({
className={clsx(
'relative z-10 flex min-h-0 flex-col overflow-hidden bg-surface-primary',
layout === 'floating'
- ? 'max-h-full rounded-md border shadow-[0_3px_0_var(--border)]'
+ ? 'max-h-full rounded-md border shadow-[0_3px_0_var(--border)] @max-[48rem]/workflow-editor:h-full'
: 'h-full !rounded-none'
)}
>
@@ -101,6 +102,7 @@ export function HogFlowEditorPanel({
)}
>
<LemonButton
+ aria-label="Back to steps"
size="small"
icon={<IconArrowLeft />}
onClick={() => setSelectedNodeId(null)}
diff --git a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelResizeHandle.tsx b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelResizeHandle.tsx
index b9a6d318322c..8c7782d29cb6 100644
--- a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelResizeHandle.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelResizeHandle.tsx
@@ -73,7 +73,7 @@ export function HogFlowEditorPanelResizeHandle({
aria-valuenow={visibleWidth}
aria-valuemin={minWidth}
aria-valuemax={maxWidth}
- className="group absolute top-4 bottom-4 left-0 z-20 w-3 cursor-ew-resize border-0 bg-transparent p-0 opacity-0 transition-opacity hover:opacity-100 focus-visible:opacity-100"
+ className="group absolute top-4 bottom-4 left-0 z-20 w-3 cursor-ew-resize border-0 bg-transparent p-0 opacity-0 transition-opacity hover:opacity-100 focus-visible:opacity-100 @max-[48rem]/workflow-editor:hidden"
onPointerDown={startResize}
onPointerMove={resize}
onDoubleClick={onReset}