From af3e869fcdc68cbb3e143be7bc94032b90e8e474 Mon Sep 17 00:00:00 2001 From: Andres Galindo Date: Wed, 17 Jan 2024 12:56:52 -0800 Subject: [PATCH] Remove content item data keys that are no longer valid when item is being created (#2444) --- 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;