From 8019740d0a48aab1d56807f7560c9f649526f8e3 Mon Sep 17 00:00:00 2001 From: Andres Date: Tue, 9 Jan 2024 12:34:08 -0800 Subject: [PATCH] Remove content item data keys that are no longer valid when item is being created --- src/shell/store/content.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/shell/store/content.js b/src/shell/store/content.js index 045e77b186..9721087aa0 100644 --- a/src/shell/store/content.js +++ b/src/shell/store/content.js @@ -470,6 +470,13 @@ export function createItem(modelZUID, itemZUID) { // Temp timestamp for sorting delete item.meta.createdAt; + // Remove content item data keys that are not in the fields list, this handles the case where a field is deleted/renamed from the model while the item is being created + Object.keys(item.data).forEach((key) => { + if (!fields.find((field) => field.name === key)) { + delete item.data[key]; + } + }); + // cover cases where the creating user zuid is missing if (!item.meta.createdByUserZUID) { item.meta.createdByUserZUID = state.user.user_zuid;