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.

feat(workflows): improve node move/copy UX with visual feedback and error handling (#65912)

Daniel Marchukb3a7a71d6aa4
diff --git a/products/workflows/frontend/Workflows/hogflows/HogFlowEditor.tsx b/products/workflows/frontend/Workflows/hogflows/HogFlowEditor.tsx
index 1a2dd2ba5562..52af806dbe08 100644
--- a/products/workflows/frontend/Workflows/hogflows/HogFlowEditor.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/HogFlowEditor.tsx
@@ -6,6 +6,7 @@ import {
Controls,
EdgeTypes,
NodeTypes,
+ Panel,
ReactFlow,
ReactFlowProvider,
useReactFlow,
@@ -13,6 +14,8 @@ import {
import { BindLogic, useActions, useValues } from 'kea'
import { useEffect, useRef } from 'react'
+import { IconInfo } from '@posthog/icons'
+
import { themeLogic } from '~/layout/navigation-3000/themeLogic'
import { workflowLogic } from '../workflowLogic'
@@ -26,7 +29,7 @@ import { HogFlowActionEdge, HogFlowActionNode } from './types'
function HogFlowEditorContent(): JSX.Element {
const { isDarkModeOn } = useValues(themeLogic)
- const { nodes, edges, dropzoneNodes } = useValues(hogFlowEditorLogic)
+ const { nodes, edges, dropzoneNodes, isMovingNode, isCopyingNode } = useValues(hogFlowEditorLogic)
const {
onEdgesChange,
onNodesChange,
@@ -73,6 +76,17 @@ function HogFlowEditorContent(): JSX.Element {
>
<Background gap={36} variant={BackgroundVariant.Dots} />
+ {(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">
+ <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>
+ </div>
+ </Panel>
+ )}
+
<Controls showInteractive={false} />
<HogFlowEditorPanel />
diff --git a/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx b/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx
index e62e994d68ef..722c602213d5 100644
--- a/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx
@@ -872,6 +872,13 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
actions.hideDropzones()
},
copyNodeToHighlightedDropzone: () => {
+ const dropzoneNode = values.dropzoneNodes.find((x) => x.id === values.highlightedDropzoneNodeId)
+ // Mirror onDrop's guard (both dropzone and node required) so the toast is reliable
+ if (!dropzoneNode || !values.nodeToBeAdded) {
+ lemonToast.error("Couldn't copy this step there. Try dropping it on a highlighted spot.")
+ actions.stopCopyingNode()
+ return
+ }
actions.onDrop()
actions.stopCopyingNode()
},
@@ -889,12 +896,14 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
const movingNodeId = values.movingNodeId!
const dropzoneNode = values.dropzoneNodes.find((x) => x.id === values.highlightedDropzoneNodeId)
if (!dropzoneNode) {
+ lemonToast.error("Couldn't move this step there. Try dropping it on a highlighted spot.")
actions.stopMovingNode()
return
}
const targetHogFlowEdge = dropzoneNode.data.edge.data?.edge
if (!targetHogFlowEdge) {
+ lemonToast.error("Couldn't move this step there. Try a different spot.")
actions.stopMovingNode()
return
}
@@ -908,6 +917,7 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
)
if (!newEdges) {
+ lemonToast.error("Couldn't move this step there. Try a different spot.")
actions.stopMovingNode()
return
}
diff --git a/products/workflows/frontend/Workflows/hogflows/steps/Nodes.tsx b/products/workflows/frontend/Workflows/hogflows/steps/Nodes.tsx
index 5ce6d664e96a..ed621470e4c6 100644
--- a/products/workflows/frontend/Workflows/hogflows/steps/Nodes.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/steps/Nodes.tsx
@@ -7,7 +7,6 @@ import { IconCopy, IconDrag, IconPlus } from '@posthog/icons'
import { hogFlowEditorLogic } from '../hogFlowEditorLogic'
import { NODE_HEIGHT, NODE_WIDTH } from '../react_flow_utils/constants'
-import type { HogFlowActionNode } from '../types'
import { StepView } from './components/StepView'
import { HogFlowStepNodeProps } from './types'
@@ -69,7 +68,7 @@ function DropzoneNode({ id }: HogFlowStepNodeProps): JSX.Element {
function HogFlowActionNode(props: HogFlowStepNodeProps): JSX.Element | null {
const updateNodeInternals = useUpdateNodeInternals()
- const { nodesById, isCopyingNode, isMovingNode, nodeToBeAdded, movingNodeId } = useValues(hogFlowEditorLogic)
+ const { nodesById } = useValues(hogFlowEditorLogic)
useEffect(() => {
updateNodeInternals(props.id)
@@ -77,17 +76,8 @@ function HogFlowActionNode(props: HogFlowStepNodeProps): JSX.Element | null {
const node = nodesById[props.id]
- const shouldWiggleCopyingNode =
- isCopyingNode && nodeToBeAdded && 'id' in nodeToBeAdded && (nodeToBeAdded as HogFlowActionNode).id === props.id
- const shouldWiggleMovingNode = isMovingNode && movingNodeId === props.id
-
return (
- <div
- className={clsx(
- 'transition-all hover:translate-y-[-2px]',
- (shouldWiggleCopyingNode || shouldWiggleMovingNode) && 'animate-bounce'
- )}
- >
+ <div className="transition-all hover:translate-y-[-2px]">
{node?.handles?.map((handle) => (
// isConnectable={false} prevents edges from being manually added
<Handle key={handle.id} className="opacity-0" {...handle} isConnectable={false} />
diff --git a/products/workflows/frontend/Workflows/hogflows/steps/components/StepView.tsx b/products/workflows/frontend/Workflows/hogflows/steps/components/StepView.tsx
index e6d9e0dee06f..45b0f77c42b7 100644
--- a/products/workflows/frontend/Workflows/hogflows/steps/components/StepView.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/steps/components/StepView.tsx
@@ -233,7 +233,12 @@ export function StepView({ action }: { action: HogFlowAction }): JSX.Element {
},
]}
>
- <LemonButton icon={<IconEllipsis />} size="xsmall" noPadding />
+ <LemonButton
+ icon={<IconEllipsis className="text-[0.65rem]" />}
+ size="xsmall"
+ tooltip="Step actions"
+ noPadding
+ />
</LemonMenu>
</div>
)}