Fix selection of field.meta.special after removal (#10412)

* Set field.meta.special to null when empty

* Add check for previously persisted empty string
This commit is contained in:
ian
2021-12-09 22:19:35 +08:00
committed by GitHub
parent b643346566
commit 81262800cb

View File

@@ -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;
}
},
});