diff --git a/packages/client/src/utils/buttonActions.js b/packages/client/src/utils/buttonActions.js index 4ab7490ae7..4de1012b01 100644 --- a/packages/client/src/utils/buttonActions.js +++ b/packages/client/src/utils/buttonActions.js @@ -542,16 +542,22 @@ export const enrichButtonActions = (actions, context) => { // then execute the rest of the actions in the chain const result = await callback() if (result !== false) { - // Generate a new total context to pass into the next enrichment + // Generate a new total context for the next enrichment buttonContext.push(result) const newContext = { ...context, actions: buttonContext } - // Enrich and call the next button action if there is more than one action remaining + // Enrich and call the next button action if there is more + // than one action remaining const next = enrichButtonActions( actions.slice(i + 1), newContext ) - resolve(typeof next === "function" ? await next() : true) + if (typeof next === "function") { + // Pass the event context back into the new action chain + resolve(await next(eventContext)) + } else { + resolve(true) + } } else { resolve(false) }