From 612771e0328f7e565d5f075cc20ad86bd1f13bce Mon Sep 17 00:00:00 2001 From: Elias Meire Date: Fri, 2 Feb 2024 11:28:12 +0100 Subject: [PATCH] fix(editor): Prune values that are not in the schema in the ResourceMapper component (#8478) --- .../components/ResourceMapper/ResourceMapper.vue | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/editor-ui/src/components/ResourceMapper/ResourceMapper.vue b/packages/editor-ui/src/components/ResourceMapper/ResourceMapper.vue index cfb17dbcb2ef9..4305657efec82 100644 --- a/packages/editor-ui/src/components/ResourceMapper/ResourceMapper.vue +++ b/packages/editor-ui/src/components/ResourceMapper/ResourceMapper.vue @@ -430,15 +430,17 @@ function emitValueChanged(): void { } function pruneParamValues(): void { - if (!state.paramValue.value) { + const { value, schema } = state.paramValue; + if (!value) { return; } - const valueKeys = Object.keys(state.paramValue.value); - valueKeys.forEach((key) => { - if (state.paramValue.value && state.paramValue.value[key] === null) { - delete state.paramValue.value[key]; + + const schemaKeys = new Set(schema.map((s) => s.id)); + for (const key of Object.keys(value)) { + if (value[key] === null || !schemaKeys.has(key)) { + delete value[key]; } - }); + } } defineExpose({