From e7061647da6e2989166a201bc30a1526febe817c Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 15 Nov 2022 12:52:06 +0000 Subject: [PATCH] Ensure action parameters can never be null and fix display of close screen modal action --- .../ButtonActionDrawer.svelte | 22 +++++++++---------- .../actions/CloseScreenModal.svelte | 9 ++++++-- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/ButtonActionDrawer.svelte b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/ButtonActionDrawer.svelte index ef7c81233b..1d18fa3a92 100644 --- a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/ButtonActionDrawer.svelte +++ b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/ButtonActionDrawer.svelte @@ -23,14 +23,18 @@ export let bindings = [] export let nested - $: showAvailableActions = !actions?.length - let actionQuery - $: parsedQuery = - typeof actionQuery === "string" ? actionQuery.toLowerCase().trim() : "" - let selectedAction = actions?.length ? actions[0] : null + $: { + // Ensure parameters object is never null + if (selectedAction && !selectedAction.parameters) { + selectedAction.parameters = {} + } + } + $: parsedQuery = + typeof actionQuery === "string" ? actionQuery.toLowerCase().trim() : "" + $: showAvailableActions = !actions?.length $: mappedActionTypes = actionTypes.reduce((acc, action) => { let parsedName = action.name.toLowerCase().trim() if (parsedQuery.length && parsedName.indexOf(parsedQuery) < 0) { @@ -40,7 +44,6 @@ acc[action.type].push(action) return acc }, {}) - // These are ephemeral bindings which only exist while executing actions $: eventContexBindings = getEventContextBindings( $currentAsset, @@ -50,9 +53,8 @@ selectedAction?.id ) $: allBindings = eventContexBindings.concat(bindings) - - // Assign a unique ID to each action $: { + // Ensure each action has a unique ID if (actions) { actions.forEach(action => { if (!action.id) { @@ -61,13 +63,11 @@ }) } } - $: selectedActionComponent = selectedAction && actionTypes.find(t => t.name === selectedAction[EVENT_TYPE_KEY])?.component - - // Select the first action if we delete an action $: { + // Select the first action if we delete an action if (selectedAction && !actions?.includes(selectedAction)) { selectedAction = actions?.[0] } diff --git a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/CloseScreenModal.svelte b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/CloseScreenModal.svelte index 5f3b3ef639..d01a085a23 100644 --- a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/CloseScreenModal.svelte +++ b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/CloseScreenModal.svelte @@ -6,9 +6,11 @@ export let bindings = [] -Navigate To screen, or leave blank. -
+ + You can optionally navigate to another screen after closing the screen + modal. +