From 8b7337f9eec26821305bf4a749340240b72f0607 Mon Sep 17 00:00:00 2001
From: Javier Segarra <jsegarra@verdnatura.es>
Date: Tue, 14 Jan 2025 08:37:10 +0100
Subject: [PATCH] fix: vnlocation

---
 src/components/common/VnLocation.vue | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/components/common/VnLocation.vue b/src/components/common/VnLocation.vue
index f5822218727..3ede24274d9 100644
--- a/src/components/common/VnLocation.vue
+++ b/src/components/common/VnLocation.vue
@@ -2,7 +2,7 @@
 import CreateNewPostcode from 'src/components/CreateNewPostcodeForm.vue';
 import VnSelectDialog from 'components/common/VnSelectDialog.vue';
 import { useI18n } from 'vue-i18n';
-import { computed } from 'vue';
+import { ref, watch } from 'vue';
 import { useAttrs } from 'vue';
 import { useRequired } from 'src/composables/useRequired';
 const { t } = useI18n();
@@ -16,6 +16,14 @@ const props = defineProps({
     },
 });
 
+watch(
+    () => props.location,
+    (newValue) => {
+        if (!modelValue.value) return;
+        modelValue.value = formatLocation(newValue) ?? null;
+    }
+);
+
 const mixinRules = [requiredFieldRule];
 const locationProperties = [
     'postcode',
@@ -43,9 +51,7 @@ const formatLocation = (obj, properties = locationProperties) => {
     return filteredParts.join(', ');
 };
 
-const modelValue = computed(() =>
-    props.location ? formatLocation(props.location, locationProperties) : null
-);
+const modelValue = ref(props.location ? formatLocation(props.location) : null);
 
 function showLabel(data) {
     const dataProperties = [