From b08bfc25173c3863f5edc684f282982d3cf3280f Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 2 May 2024 10:48:44 +0100 Subject: [PATCH] Fix bug where adding a confirmation step to a button action chain would break event context in further actions --- packages/client/src/utils/buttonActions.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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) }