From 575cb55402a096f66db19f27163cf548df7f9005 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 19 Apr 2021 14:37:04 +0100 Subject: [PATCH] Fix multiple bugs with ID numbering in the event editor --- .../EventsEditor/EventEditor.svelte | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/EventEditor.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/EventEditor.svelte index fce9911754..b7932afb40 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/EventEditor.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/EventEditor.svelte @@ -3,6 +3,7 @@ import { dndzone } from "svelte-dnd-action" import { Button, DropdownMenu, Spacer } from "@budibase/bbui" import actionTypes from "./actions" + import { generate } from "shortid" const flipDurationMs = 150 @@ -11,10 +12,14 @@ export let actions // dndzone needs an id on the array items, so this adds some temporary ones. - if (actions) { - actions = actions.map((action, i) => { - return { ...action, id: i } - }) + $: { + if (actions) { + actions.forEach(action => { + if (!action.id) { + action.id = generate() + } + }) + } } let addActionButton @@ -41,7 +46,7 @@ const newAction = { parameters: {}, [EVENT_TYPE_KEY]: actionType.name, - id: actions ? actions.length + 1 : 0, + id: generate(), } if (!actions) { actions = []