From 81262800cb271e033cc865dcd620f8061579579c Mon Sep 17 00:00:00 2001 From: ian Date: Thu, 9 Dec 2021 22:19:35 +0800 Subject: [PATCH] Fix selection of field.meta.special after removal (#10412) * Set field.meta.special to null when empty * Add check for previously persisted empty string --- .../field-detail-advanced-schema.vue | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/src/modules/settings/routes/data-model/field-detail/field-detail-advanced/field-detail-advanced-schema.vue b/app/src/modules/settings/routes/data-model/field-detail/field-detail-advanced/field-detail-advanced-schema.vue index 366064bb73..1f86e584ea 100644 --- a/app/src/modules/settings/routes/data-model/field-detail/field-detail-advanced/field-detail-advanced-schema.vue +++ b/app/src/modules/settings/routes/data-model/field-detail/field-detail-advanced/field-detail-advanced-schema.vue @@ -376,6 +376,11 @@ export default defineComponent({ return null; }, set(newOption: string | null) { + // In case of previously persisted empty string + if (typeof special.value === 'string') { + special.value = []; + } + special.value = (special.value ?? []).filter( (special: string) => onCreateSpecials.includes(special) === false ); @@ -383,6 +388,11 @@ export default defineComponent({ if (newOption) { special.value = [...(special.value ?? []), newOption]; } + + // Prevent empty array saved as empty string + if (special.value && special.value.length === 0) { + special.value = null; + } }, }); @@ -447,6 +457,11 @@ export default defineComponent({ return null; }, set(newOption: string | null) { + // In case of previously persisted empty string + if (typeof special.value === 'string') { + special.value = []; + } + special.value = (special.value ?? []).filter( (special: string) => onUpdateSpecials.includes(special) === false ); @@ -454,6 +469,11 @@ export default defineComponent({ if (newOption) { special.value = [...(special.value ?? []), newOption]; } + + // Prevent empty array saved as empty string + if (special.value && special.value.length === 0) { + special.value = null; + } }, });