From 631ca111024ac8a54b5926ae9fa6697925ebe5d7 Mon Sep 17 00:00:00 2001 From: Mert Sincan Date: Tue, 7 Jan 2025 10:16:02 +0000 Subject: [PATCH] Refactor #7049 - added findNonEmpty to track change detection --- .../core/src/baseeditableholder/BaseEditableHolder.vue | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/core/src/baseeditableholder/BaseEditableHolder.vue b/packages/core/src/baseeditableholder/BaseEditableHolder.vue index 800e15824..9d9790c45 100644 --- a/packages/core/src/baseeditableholder/BaseEditableHolder.vue +++ b/packages/core/src/baseeditableholder/BaseEditableHolder.vue @@ -93,6 +93,10 @@ export default { this.$emit('value-change', value); this.formField.onChange?.({ originalEvent: event, value }); + }, + // @todo move to @primeuix/utils + findNonEmpty(...values) { + return values.find(isNotEmpty); } }, computed: { @@ -100,7 +104,7 @@ export default { return isNotEmpty(this.d_value); }, $invalid() { - return this.invalid ?? this.$pcFormField?.$field?.invalid ?? this.$pcForm?.states?.[this.$formName]?.invalid; + return this.findNonEmpty(this.invalid, this.$pcFormField?.$field?.invalid, this.$pcForm?.states?.[this.$formName]?.invalid); }, $formName() { return this.name || this.$formControl?.name; @@ -109,10 +113,10 @@ export default { return this.formControl || this.$pcFormField?.formControl; }, $formDefaultValue() { - return this.d_value ?? this.$pcFormField?.initialValue ?? this.$pcForm?.initialValues?.[this.$formName]; + return this.findNonEmpty(this.d_value, this.$pcFormField?.initialValue, this.$pcForm?.initialValues?.[this.$formName]); }, $formValue() { - return this.$pcFormField?.$field?.value ?? this.$pcForm?.states?.[this.$formName]?.value; + return this.findNonEmpty(this.$pcFormField?.$field?.value, this.$pcForm?.states?.[this.$formName]?.value); }, controlled() { return this.$inProps.hasOwnProperty('modelValue') || (!this.$inProps.hasOwnProperty('modelValue') && !this.$inProps.hasOwnProperty('defaultValue'));