: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): save a broadcast draft's name when the name field loses focus (#108147)
Daniel Marchukf029a88f0020
diff --git a/products/workflows/frontend/Broadcasts/BroadcastSceneHeader.tsx b/products/workflows/frontend/Broadcasts/BroadcastSceneHeader.tsxindex b994bc336e6c..9faa79b9b5ee 100644--- a/products/workflows/frontend/Broadcasts/BroadcastSceneHeader.tsx+++ b/products/workflows/frontend/Broadcasts/BroadcastSceneHeader.tsx@@ -14,21 +14,24 @@ export interface BroadcastSceneHeaderProps {/** The broadcast wizard and summary header, shaped like the workflow editor's. */export function BroadcastSceneHeader({ canEdit = false, nameSuffix, actions }: BroadcastSceneHeaderProps): JSX.Element {const { name, broadcast, broadcastLoading } = useValues(broadcastWizardLogic)- const { setName } = useActions(broadcastWizardLogic)+ const { setName, saveName } = useActions(broadcastWizardLogic)return (- <SceneTitleSection- name={name}- description={null}- resourceType={{ type: 'broadcasts' }}- canEdit={canEdit}- // Each keystroke lands in the wizard's state, which Continue saves. A blur-save would reach it a tick- // after a click on Continue, so that save would carry the old name.- onNameChange={setName}- renameDebounceMs={0}- isLoading={broadcastLoading && !broadcast}- nameSuffix={nameSuffix}- actions={actions}- />+ // Blur from the name field saves a draft's rename. Actions in the header blur other elements.+ <div onBlur={(e) => (e.target as HTMLElement).getAttribute('name') === 'name' && saveName()}>+ <SceneTitleSection+ name={name}+ description={null}+ resourceType={{ type: 'broadcasts' }}+ canEdit={canEdit}+ // Each keystroke lands in the wizard's state, so a click on Continue straight after typing saves the+ // new name. The blur save above reaches it a tick later.+ onNameChange={setName}+ renameDebounceMs={0}+ isLoading={broadcastLoading && !broadcast}+ nameSuffix={nameSuffix}+ actions={actions}+ />+ </div>)}diff --git a/products/workflows/frontend/Broadcasts/broadcastWizardLogic.test.ts b/products/workflows/frontend/Broadcasts/broadcastWizardLogic.test.tsindex 6bfb51668b01..f250bd94110d 100644--- a/products/workflows/frontend/Broadcasts/broadcastWizardLogic.test.ts+++ b/products/workflows/frontend/Broadcasts/broadcastWizardLogic.test.ts@@ -59,12 +59,14 @@ describe('broadcastWizardLogic', () => {let latest: HogFlowApilet releaseCreate: () => voidlet patchedSubjects: string[]+ let patchedNames: string[]let holdPatch: Promise<void> | nulllet onPatchStarted: (() => void) | nulllet failPatches: numberbeforeEach(() => {patchedSubjects = []+ patchedNames = []holdPatch = nullonPatchStarted = nullfailPatches = 0@@ -84,7 +86,14 @@ describe('broadcastWizardLogic', () => {},patch: {'/api/projects/:team_id/hog_flows/:id/': async ({ request }) => {- const body = (await request.json()) as { actions: any[] }+ const body = (await request.json()) as { actions?: any[]; name?: string }+ if (!body.actions) {+ patchedNames.push(body.name ?? '')+ return [+ 200,+ savedBroadcast({ name: body.name ?? '', subject: '', updatedAt: '2026-09-24T10:00:05Z' }),+ ]+ }const subject = body.actions.find((action) => action.type === 'function_email').config.inputs.email.value.subjectif (failPatches > 0) {@@ -145,6 +154,28 @@ describe('broadcastWizardLogic', () => {})+ it.each([+ { case: 'a renamed draft', status: 'draft', name: 'Spring sale, final', saved: ['Spring sale, final'] },+ { case: 'an unchanged name', status: 'draft', name: 'Spring sale', saved: [] },+ { case: 'a blank name', status: 'draft', name: ' ', saved: [] },+ { case: 'a live broadcast', status: 'active', name: 'Spring sale, final', saved: [] },+ ])('saves the name on blur only for $case', async ({ status, name, saved }) => {+ logic.actions.draftAutosaved({+ ...savedBroadcast({ name: 'Spring sale', subject: '', updatedAt: '2026-09-24T10:00:00Z' }),+ status: status as HogFlowApi['status'],+ })+ logic.actions.setName(name)++ await expectLogic(logic, () => {+ logic.actions.saveName()+ }).toFinishAllListeners()++ expect(patchedNames).toEqual(saved)+ if (saved.length) {+ expect(logic.values.broadcast?.name).toEqual(name)+ }+ })+it('moves a new broadcast onto its draft URL once the draft is created', async () => {router.actions.push('/broadcasts/new')await expectLogic(logic, () => {diff --git a/products/workflows/frontend/Broadcasts/broadcastWizardLogic.ts b/products/workflows/frontend/Broadcasts/broadcastWizardLogic.tsindex 6067df5101c3..44fb8820deb0 100644--- a/products/workflows/frontend/Broadcasts/broadcastWizardLogic.ts+++ b/products/workflows/frontend/Broadcasts/broadcastWizardLogic.ts@@ -291,6 +291,9 @@ export interface broadcastWizardLogicActions {saveBroadcastFinished: (broadcast: HogFlowApi | null) => {broadcast: HogFlowApi | null}+ saveName: () => {+ value: true+ }setAudienceProperties: (properties: AnyPropertyFilter[]) => {properties: AnyPropertyFilter[]}@@ -445,6 +448,7 @@ export const broadcastWizardLogic = kea<broadcastWizardLogicType>([prevStep: true,continueStep: true,setName: (name: string) => ({ name }),+ saveName: true,setAudienceProperties: (properties: AnyPropertyFilter[]) => ({ properties }),setGoalEnabled: (enabled: boolean) => ({ enabled }),setConversion: (conversion: HogFlowConversionApi) => ({ conversion }),@@ -1087,6 +1091,43 @@ export const broadcastWizardLogic = kea<broadcastWizardLogicType>([}actions.replayDeferredEdit()},+ saveName: async () => {+ // A new broadcast has no draft yet, and a live one is not renamed in place.+ if (+ !values.name.trim() ||+ !values.broadcastId ||+ !values.currentProjectId ||+ values.broadcast?.status !== 'draft' ||+ values.name === values.broadcast.name+ ) {+ return+ }+ const projectId = String(values.currentProjectId)+ try {+ await getSaveQueue(cache, values).run(async () => {+ actions.draftAutosaved(+ await patchWithoutClobbering(+ projectId,+ values.broadcastId!,+ { name: values.name },+ values.broadcast?.updated_at+ )+ )+ })+ } catch (error: any) {+ if (error instanceof EditedElsewhereError) {+ // The rename stays local unless the other edit renamed it too, and the next save carries it.+ const attempted = values.name+ actions.applyExternalEdit(error.latest, values.broadcast)+ if (values.name !== attempted) {+ lemonToast.info("This broadcast was renamed somewhere else, so your new name wasn't saved.")+ }+ } else {+ lemonToast.error(`Couldn't save the name: ${error?.detail || error?.message || 'unknown error'}`)+ }+ }+ actions.replayDeferredEdit()+ },saveBroadcastFinished: () => {actions.replayDeferredEdit()},