: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
feat(workflows): drag a step out of the palette onto the tile canvas (#128000)
Michael Reichenbachf3e64fc8e996
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/CommandBar.tsx b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/CommandBar.tsxindex a5e903af3705..ece8ece47297 100644--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/CommandBar.tsx+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/CommandBar.tsx@@ -3,21 +3,29 @@ import { useMemo, useRef } from 'react'import { IconPlus } from '@posthog/icons'+import { cn } from 'lib/utils/css-classes'+import { StepPalette } from './StepPalette'import { tileCanvasLogic } from './tileCanvasLogic'import { CanvasCommand, useCanvasCommands } from './useCanvasCommands'export function CommandBar(): JSX.Element {const triggerRef = useRef<HTMLButtonElement>(null)- const { commandPaletteQuery, paletteSections } = useValues(tileCanvasLogic)- const { openCommandPalette, closeCommandPalette, startPlacing } = useActions(tileCanvasLogic)+ const { commandPaletteQuery, paletteSections, isDraggingNewStep } = useValues(tileCanvasLogic)+ const { openCommandPalette, closeCommandPalette, startPlacing, startDraggingNewStep, endDraggingNewStep } =+ useActions(tileCanvasLogic)const { panel, view } = useCanvasCommands()const commands = useMemo((): CanvasCommand[] => [...panel, ...view], [panel, view])return (<div className="relative">{commandPaletteQuery !== null && (- <div className="absolute bottom-full left-1/2 mb-3 -translate-x-1/2">+ <div+ className={cn(+ 'absolute bottom-full left-1/2 mb-3 -translate-x-1/2',+ isDraggingNewStep && 'invisible'+ )}+ ><StepPalettekey={commandPaletteQuery}sections={paletteSections}@@ -26,6 +34,8 @@ export function CommandBar(): JSX.Element {placeholder="Add a step or run a command"trigger={triggerRef}onSelectStep={startPlacing}+ onDragStep={startDraggingNewStep}+ onDragEnd={endDraggingNewStep}onClose={closeCommandPalette}/></div>diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/PlacementHint.tsx b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/PlacementHint.tsxindex 02daa23cdbfa..81c44546e0a0 100644--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/PlacementHint.tsx+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/PlacementHint.tsx@@ -6,10 +6,10 @@ import { LemonButton } from '@posthog/lemon-ui'import { tileCanvasLogic } from './tileCanvasLogic'export function PlacementHint(): JSX.Element | null {- const { nodeToBeAdded, isMovingNode, isCopyingNode, isDraggingStep } = useValues(tileCanvasLogic)+ const { nodeToBeAdded, isMovingNode, isCopyingNode, isDraggingStep, isDraggingNewStep } = useValues(tileCanvasLogic)const { cancel } = useActions(tileCanvasLogic)const action = isMovingNode ? 'move the step there' : isCopyingNode ? 'copy the step there' : null- const verb = isDraggingStep ? 'Drop on' : 'Click'+ const verb = isDraggingStep || isDraggingNewStep ? 'Drop on' : 'Click'if (!action && !nodeToBeAdded) {return null}@@ -22,7 +22,7 @@ export function PlacementHint(): JSX.Element | null {</>) : (<>- Click a highlighted + to add{' '}+ {verb} a highlighted + to add{' '}<strong>{nodeToBeAdded && 'data' in nodeToBeAdded ? nodeToBeAdded.data.name : nodeToBeAdded?.name}</strong>diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/QuickAddButton.tsx b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/QuickAddButton.tsxindex abb6c22a5d96..8a5712a342ec 100644--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/QuickAddButton.tsx+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/QuickAddButton.tsx@@ -12,6 +12,16 @@ import { StepPalette } from './StepPalette'import { tileCanvasLogic } from './tileCanvasLogic'import { Point } from './tileCanvasModel'+function buttonLook(isDropTarget: boolean, isActive: boolean, revealed: boolean): string {+ if (isDropTarget) {+ return 'scale-[1.6] border-[var(--color-accent)] bg-[var(--color-accent)] text-white shadow-md'+ }+ if (isActive) {+ return 'scale-125 border-[var(--color-accent)] text-[var(--color-accent)] shadow'+ }+ return revealed ? 'opacity-100' : 'opacity-0 hover:opacity-100 focus-visible:opacity-100'+}+export function QuickAddButton({edge,at,@@ -26,11 +36,13 @@ export function QuickAddButton({isDropTarget?: boolean}): JSX.Element | null {const buttonRef = useRef<HTMLButtonElement>(null)- const { quickAddEdgeKey, isPlacing, paletteSections, placementLabel, placeableEdgeKeys } =+ const { quickAddEdgeKey, isPlacing, paletteSections, placementLabel, placeableEdgeKeys, isDraggingNewStep } =useValues(tileCanvasLogic)- const { openQuickAdd, closeQuickAdd, addStepAt, placeAt } = useActions(tileCanvasLogic)+ const { openQuickAdd, closeQuickAdd, addStepAt, placeAt, startDraggingNewStep, endDraggingNewStep } =+ useActions(tileCanvasLogic)const key = getEdgeId(edge)const isOpen = quickAddEdgeKey === key+ const label = isPlacing ? 'Place the step here' : 'Add a step here'if (placeableEdgeKeys && !placeableEdgeKeys.has(key)) {return null@@ -43,14 +55,19 @@ export function QuickAddButton({><Popovervisible={isOpen}+ className={isDraggingNewStep ? 'invisible' : undefined}placement="right-start"- fallbackPlacements={['left-start', 'left', 'left-end', 'bottom-start', 'top-start']}+ // Side placements only. The popover puts its gap on the side that faces the +, so a top or bottom+ // placement changes the window's size, and near an edge flip then swaps placements on every frame.+ fallbackPlacements={['left-start', 'left', 'left-end']}overlay={<StepPalettesections={paletteSections}placeholder="Search steps"trigger={buttonRef}onSelectStep={(step) => addStepAt(step, edge)}+ onDragStep={startDraggingNewStep}+ onDragEnd={endDraggingNewStep}onClose={closeQuickAdd}/>}@@ -58,19 +75,13 @@ export function QuickAddButton({<buttontype="button"ref={buttonRef}- aria-label={isPlacing ? 'Place the step here' : 'Add a step here'}- title={isPlacing ? 'Place the step here' : 'Add a step here'}+ aria-label={label}+ title={label}data-attr="workflow-tile-quick-add"onClick={() => (isPlacing ? placeAt(edge) : isOpen ? closeQuickAdd() : openQuickAdd(key))}className={cn('flex size-5 cursor-pointer items-center justify-center rounded-full border bg-surface-primary text-secondary transition-all duration-200 ease-out hover:scale-125 hover:border-[var(--color-accent)] hover:text-[var(--color-accent)] motion-reduce:transition-none',- isDropTarget- ? 'scale-[1.6] border-[var(--color-accent)] bg-[var(--color-accent)] text-white shadow-md'- : isPlacing || isOpen- ? 'scale-125 border-[var(--color-accent)] text-[var(--color-accent)] shadow'- : revealed- ? 'opacity-100'- : 'opacity-0 hover:opacity-100 focus-visible:opacity-100'+ buttonLook(isDropTarget, isPlacing || isOpen, revealed))}><IconPlus className="text-xs" />diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/StepPalette.test.tsx b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/StepPalette.test.tsxindex ba90322c1c33..bb3757b756cb 100644--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/StepPalette.test.tsx+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/StepPalette.test.tsx@@ -6,6 +6,7 @@ import { createRef } from 'react'import { initKeaTests } from '~/test/init'import { StepPalette } from './StepPalette'+import { STEP_DRAG_DATA_TYPE } from './tileCanvasModel'import type { PaletteSection } from './tileCanvasModel'const SECTIONS: PaletteSection[] = [@@ -18,8 +19,16 @@ const SECTIONS: PaletteSection[] = [},]-function renderPalette(): { onSelectStep: jest.Mock; onClose: jest.Mock; trigger: HTMLButtonElement } {+function renderPalette(): {+ onSelectStep: jest.Mock+ onDragStep: jest.Mock+ onDragEnd: jest.Mock+ onClose: jest.Mock+ trigger: HTMLButtonElement+} {const onSelectStep = jest.fn()+ const onDragStep = jest.fn()+ const onDragEnd = jest.fn()const onClose = jest.fn()const triggerRef = createRef<HTMLButtonElement>()render(@@ -30,11 +39,13 @@ function renderPalette(): { onSelectStep: jest.Mock; onClose: jest.Mock; triggerplaceholder="Search steps"trigger={triggerRef}onSelectStep={onSelectStep}+ onDragStep={onDragStep}+ onDragEnd={onDragEnd}onClose={onClose}/></>)- return { onSelectStep, onClose, trigger: triggerRef.current as HTMLButtonElement }+ return { onSelectStep, onDragStep, onDragEnd, onClose, trigger: triggerRef.current as HTMLButtonElement }}describe('StepPalette', () => {@@ -63,6 +74,34 @@ describe('StepPalette', () => {expect(onSelectStep).toHaveBeenCalledWith(SECTIONS[0].steps[0])})+ it.each([+ { when: 'after the frame that draws the drag image', endsFirst: false, starts: true },+ { when: 'never, for a drag that ends before that frame', endsFirst: true, starts: false },+ ])('starts dragging a step $when', ({ endsFirst, starts }) => {+ jest.useFakeTimers()+ try {+ const { onDragStep, onDragEnd } = renderPalette()+ const row = screen.getByText('Delay').closest('[draggable]') as HTMLElement+ const dataTransfer = { setData: jest.fn(), effectAllowed: 'none' }++ fireEvent.dragStart(row, { dataTransfer })+ expect(onDragStep).not.toHaveBeenCalled()+ if (endsFirst) {+ fireEvent.dragEnd(row, { dataTransfer })+ }+ jest.runOnlyPendingTimers()+ if (!endsFirst) {+ fireEvent.dragEnd(row, { dataTransfer })+ }++ expect(onDragStep.mock.calls).toEqual(starts ? [[SECTIONS[0].steps[0]]] : [])+ expect(onDragEnd).toHaveBeenCalledTimes(starts ? 1 : 0)+ expect(dataTransfer.setData.mock.calls).toEqual([[STEP_DRAG_DATA_TYPE, 'delay']])+ } finally {+ jest.useRealTimers()+ }+ })+it('gives focus back to the button that opened it on Escape', () => {const { onClose, trigger } = renderPalette()diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/StepPalette.tsx b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/StepPalette.tsxindex b757aab3c222..b651d5af6065 100644--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/StepPalette.tsx+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/StepPalette.tsx@@ -53,6 +53,8 @@ export function StepPalette({placeholder,trigger,onSelectStep,+ onDragStep,+ onDragEnd,onClose,}: {sections: PaletteSection[]@@ -61,6 +63,8 @@ export function StepPalette({placeholder: stringtrigger?: RefObject<HTMLElement>onSelectStep: (step: CreateActionType) => void+ onDragStep: (step: CreateActionType) => void+ onDragEnd: () => voidonClose: () => void}): JSX.Element {const [query, setQuery] = useState(initialQuery)@@ -68,12 +72,21 @@ export function StepPalette({const rootRef = useRef<HTMLDivElement>(null)const listRef = useRef<HTMLDivElement>(null)const inputRef = useRef<HTMLInputElement>(null)+ const dragFrameRef = useRef<number | null>(null)const listId = useId()const optionId = (index: number): string => `${listId}-option-${index}`const items = useMemo(() => filterPaletteItems(query, sections, commands), [query, sections, commands])useComboboxInput(inputRef, listId, items.length ? optionId(activeIndex) : undefined)useCloseOnPointerOutside(rootRef, trigger, onClose)+ useEffect(+ () => () => {+ if (dragFrameRef.current !== null) {+ cancelAnimationFrame(dragFrameRef.current)+ }+ },+ []+ )useEffect(() => setActiveIndex(0), [query])useEffect(() => {listRef.current?.querySelector(`[data-index="${activeIndex}"]`)?.scrollIntoView({ block: 'nearest' })@@ -91,6 +104,23 @@ export function StepPalette({}}+ // The browser draws the drag image after dragstart, so the palette may hide only a frame later.+ const startDrag = (step: CreateActionType): void => {+ dragFrameRef.current = requestAnimationFrame(() => {+ dragFrameRef.current = null+ onDragStep(step)+ })+ }++ const endDrag = (): void => {+ if (dragFrameRef.current !== null) {+ cancelAnimationFrame(dragFrameRef.current)+ dragFrameRef.current = null+ return+ }+ onDragEnd()+ }+const onKeyDown = (event: KeyboardEvent<HTMLDivElement>): void => {const command = paletteKeyCommand(event)if (command === 'close') {@@ -151,6 +181,8 @@ export function StepPalette({active={index === activeIndex}onHover={() => setActiveIndex(index)}onChoose={() => choose(item)}+ onDragStep={startDrag}+ onDragEnd={endDrag}/></div>))}diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/StepPaletteRow.tsx b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/StepPaletteRow.tsxindex f2fcf5840a51..c6c84d09260c 100644--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/StepPaletteRow.tsx+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/StepPaletteRow.tsx@@ -1,6 +1,9 @@+import { IconDrag } from '@posthog/icons'import { LemonButton } from '@posthog/lemon-ui'+import type { CreateActionType } from '../../hogFlowEditorLogic'import { StepIcon } from './StepIcon'+import { STEP_DRAG_DATA_TYPE } from './tileCanvasModel'import type { PaletteItem } from './tileCanvasModel'import type { CanvasCommand } from './useCanvasCommands'@@ -11,6 +14,8 @@ export function StepPaletteRow({active,onHover,onChoose,+ onDragStep,+ onDragEnd,}: {item: PaletteItem<CanvasCommand>id: string@@ -18,8 +23,10 @@ export function StepPaletteRow({active: booleanonHover: () => voidonChoose: () => void+ onDragStep: (step: CreateActionType) => void+ onDragEnd: () => void}): JSX.Element {- return (+ const button = (<LemonButtonfullWidthsize="small"@@ -37,6 +44,7 @@ export function StepPaletteRow({</span>)}+ sideIcon={item.kind === 'step' && active ? <IconDrag className="text-secondary" /> : undefined}onMouseEnter={onHover}onClick={onChoose}>@@ -48,4 +56,20 @@ export function StepPaletteRow({</span></LemonButton>)+ if (item.kind !== 'step') {+ return button+ }+ return (+ <div+ draggable+ onDragStart={(event) => {+ event.dataTransfer.effectAllowed = 'move'+ event.dataTransfer.setData(STEP_DRAG_DATA_TYPE, item.step.type)+ onDragStep(item.step)+ }}+ onDragEnd={onDragEnd}+ >+ {button}+ </div>+ )}diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileCanvasContent.tsx b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileCanvasContent.tsxindex 92ad29a557f3..41dcff63e838 100644--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileCanvasContent.tsx+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileCanvasContent.tsx@@ -72,6 +72,7 @@ export function TileCanvasContent(): JSX.Element {templateNameOf,nodeToBeAdded,isDraggingStep,+ isDraggingNewStep,placeableEdgeKeys,dropTargetEdgeKey,} = useValues(tileCanvasLogic)@@ -214,7 +215,7 @@ export function TileCanvasContent(): JSX.Element {className={cn('!mb-5', isPanelOpen && '@max-[48rem]/workflow-editor:hidden')}><div className="flex flex-col items-center gap-2">- {commandPaletteQuery === null && <PlacementHint />}+ {(commandPaletteQuery === null || isDraggingNewStep) && <PlacementHint />}<CommandBar /></div></Panel>diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileStepNode.tsx b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileStepNode.tsxindex 6d1befc3e832..33c18c970361 100644--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileStepNode.tsx+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileStepNode.tsx@@ -7,7 +7,7 @@ import { StepImportNotesBadge } from '../../../import/StepImportNotesBadge'import { canMoveStep } from '../../hogFlowEditorLogic'import type { HogFlow, HogFlowAction } from '../../types'import { tileCanvasLogic } from './tileCanvasLogic'-import { hasStepMenu } from './tileCanvasModel'+import { hasStepMenu, STEP_DRAG_DATA_TYPE } from './tileCanvasModel'import { TileCaption } from './TileCaption'import { TileFace } from './TileFace'import { HOVER_CARD_CLOSE_MS, TileHoverCard } from './TileHoverCard'@@ -76,8 +76,7 @@ export function TileStepNode({draggable? (event) => {event.dataTransfer.effectAllowed = 'move'- // Firefox starts a drag only when it carries data.- event.dataTransfer.setData('text/plain', action.id)+ event.dataTransfer.setData(STEP_DRAG_DATA_TYPE, action.id)startDraggingStep(action.id)}: undefineddiff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasLogic.test.ts b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasLogic.test.tsindex d63d5ac396b1..d65e34dc14e1 100644--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasLogic.test.ts+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasLogic.test.ts@@ -238,6 +238,15 @@ describe('tileCanvasLogic', () => {source: 'quick add',add: (): void => logic.actions.addStepAt(delayStep, logic.values.workflow.edges[0]),},+ {+ source: 'drag',+ add: (): void => {+ logic.actions.openCommandPalette('d')+ logic.actions.startDraggingNewStep(delayStep)+ logic.actions.dropAt(logic.values.workflow.edges[0])+ logic.actions.endDraggingNewStep()+ },+ },])('counts a step added from the $source', ({ source, add }) => {const capture = jest.spyOn(posthog, 'capture')@@ -246,6 +255,47 @@ describe('tileCanvasLogic', () => {expect(capture).toHaveBeenCalledWith('workflows tile canvas step added', { source, step_type: 'delay' })})+ it.each([+ { outcome: 'lands on a +', fromAddWindow: false, drop: true, dragEnds: true, stillOpen: false },+ // The drop replaces the arrow of the + that opened the add window, so the window and its dragend go away.+ {+ outcome: 'lands on the + that opened it',+ fromAddWindow: true,+ drop: true,+ dragEnds: false,+ stillOpen: false,+ },+ { outcome: 'lets go elsewhere', fromAddWindow: false, drop: false, dragEnds: true, stillOpen: true },+ ])(+ 'closes the palette only when a step dragged out of it $outcome',+ async ({ fromAddWindow, drop, dragEnds, stillOpen }) => {+ const stepsBefore = logic.values.workflow.actions.length+ const edge = logic.values.workflow.edges[0]+ if (fromAddWindow) {+ logic.actions.openQuickAdd(getEdgeId(edge))+ } else {+ logic.actions.openCommandPalette('d')+ }+ logic.actions.startDraggingNewStep(delayStep)+ if (drop) {+ logic.actions.dropAt(edge)+ }++ await expectLogic(logic, () => {+ if (dragEnds) {+ logic.actions.endDraggingNewStep()+ }+ }).toMatchValues({+ nodeToBeAdded: null,+ isDraggingNewStep: false,+ })+ expect(logic.values.commandPaletteQuery !== null || logic.values.quickAddEdgeKey !== null).toBe(+ stillOpen+ )+ expect(logic.values.workflow.actions).toHaveLength(stepsBefore + (drop ? 1 : 0))+ }+ )+it.each(['startMovingNode', 'startCopyingNode'] as const)('drops a pending %s when someone starts adding a step',async (startPending) => {diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasLogic.ts b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasLogic.tsindex e7a51589dcb1..ea31b5e7cb09 100644--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasLogic.ts+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasLogic.ts@@ -198,6 +198,7 @@ export interface tileCanvasLogicValues {fitRequest: numberfitsNextLayout: booleanframeSpecs: PathFrameSpec[]+ isDraggingNewStep: booleanisDraggingStep: booleanisHistoryOpen: booleanisPanelOpen: boolean@@ -309,6 +310,9 @@ export interface tileCanvasLogicActions {dropAt: (edge: HogFlowEdge) => {edge: HogFlowEdge}+ endDraggingNewStep: () => {+ value: true+ }endDraggingStep: (dropEffect?: string | null) => {dropEffect: string | null}@@ -406,6 +410,9 @@ export interface tileCanvasLogicActions {setPendingPathFocus: (pendingPathFocus: PendingPathFocus | null) => {pendingPathFocus: PendingPathFocus | null}+ startDraggingNewStep: (step: CreateActionType) => {+ step: CreateActionType+ }startDraggingStep: (actionId: string) => {actionId: string}@@ -548,6 +555,8 @@ export const tileCanvasLogic = kea<tileCanvasLogicType>([dropAt: (edge: HogFlowEdge) => ({ edge }),startDraggingStep: (actionId: string) => ({ actionId }),endDraggingStep: (dropEffect: string | null = null) => ({ dropEffect }),+ startDraggingNewStep: (step: CreateActionType) => ({ step }),+ endDraggingNewStep: true,selectStep: (actionId: string) => ({ actionId }),revealStep: (actionId: string, openPanel: boolean = true) => ({ actionId, openPanel }),openPanel: (mode: TileCanvasPanelMode) => ({ mode }),@@ -606,6 +615,14 @@ export const tileCanvasLogic = kea<tileCanvasLogicType>([cancel: () => null,},],+ isDraggingNewStep: [+ false,+ {+ startDraggingNewStep: () => true,+ endDraggingNewStep: () => false,+ cancel: () => false,+ },+ ],quickAddEdgeKey: [null as string | null,{@@ -912,7 +929,7 @@ export const tileCanvasLogic = kea<tileCanvasLogicType>([dropPendingMoveOrCopy()actions.startMovingNode(node)cache.stepDrag = { stepType: node.data.type, dropped: false }- posthog.capture('workflows tile canvas step drag started', { step_type: node.data.type })+ posthog.capture('workflows tile canvas step drag started', { kind: 'move', step_type: node.data.type })},endDraggingStep: ({ dropEffect }) => {// A drop that moved the step already ended the move, so only a drag let go elsewhere is still moving.@@ -926,6 +943,20 @@ export const tileCanvasLogic = kea<tileCanvasLogicType>([}cache.stepDrag = null},+ startDraggingNewStep: ({ step }) => {+ dropPendingMoveOrCopy()+ actions.setNodeToBeAdded(step)+ posthog.capture('workflows tile canvas step drag started', { kind: 'add', step_type: step.type })+ },+ endDraggingNewStep: () => {+ // A drop on a + adds the step and clears it, so a step still waiting means the drag let go elsewhere.+ if (values.nodeToBeAdded) {+ actions.setNodeToBeAdded(null)+ } else {+ actions.closeCommandPalette()+ actions.closeQuickAdd()+ }+ },dropAt: ({ edge }) => {const step = values.nodeToBeAddedif (values.isMovingNode) {@@ -933,6 +964,10 @@ export const tileCanvasLogic = kea<tileCanvasLogicType>([} else if (step) {actions.onDrop(undefined, edge)captureStepAdded('drag', 'data' in step ? step.data.type : step.type)+ // A drop on the + that opened the add window removes that window, so its dragend never fires.+ if (values.isDraggingNewStep) {+ actions.endDraggingNewStep()+ }}},placeAt: ({ edge }) => {diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasModel.ts b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasModel.tsindex 6b47f517a934..407ae5c60f2b 100644--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasModel.ts+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasModel.ts@@ -782,6 +782,10 @@ export interface PaletteCommand {hint?: string}+// Firefox starts a drag only when it carries data. A text field accepts a drop of text/plain and types it in,+// so step drags carry a type that no text field accepts.+export const STEP_DRAG_DATA_TYPE = 'application/x-posthog-workflow-step'+export type PaletteItem<Command extends PaletteCommand = PaletteCommand> =| { kind: 'step'; key: string; section: string; label: string; description?: string; step: CreateActionType }| { kind: 'command'; key: string; section: string; label: string; description?: string; command: Command }