diff --git a/src/components/Event/FullAddressAutoComplete.vue b/src/components/Event/FullAddressAutoComplete.vue index a827684d8..48185b32c 100644 --- a/src/components/Event/FullAddressAutoComplete.vue +++ b/src/components/Event/FullAddressAutoComplete.vue @@ -374,7 +374,7 @@ const asyncData = async (query: string): Promise => { }; const selectedAddressText = computed(() => { - if (!selected) return undefined; + if (!selected || !selected.id) return undefined; return addressFullName(selected); }); diff --git a/src/components/Home/SearchFields.vue b/src/components/Home/SearchFields.vue index afd74e414..c20315bb2 100644 --- a/src/components/Home/SearchFields.vue +++ b/src/components/Home/SearchFields.vue @@ -27,6 +27,7 @@ :default-text="locationDefaultText" labelClass="sr-only" :placeholder="t('e.g. Nantes, Berlin, Cork, …')" + v-on:update:modelValue="modelValueUpdate" /> @@ -95,6 +96,10 @@ const search = computed({ }, }); +const modelValueUpdate = (newlocation: IAddress | null) => { + emit("update:location", newlocation); +}; + const submit = () => { emit("submit"); const { lat, lon } = addressToLocation(location.value); diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index aeebdda16..5c45847c5 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -29,7 +29,8 @@ @@ -237,6 +238,7 @@ const currentUserParticipations = computed( const location = ref(null); const search = ref(""); +const noLocation = ref(false); watch(location, (newLoc, oldLoc) => console.debug("LOCATION UPDATED from", { ...oldLoc }, " to ", { ...newLoc }) @@ -428,6 +430,13 @@ const currentUserLocation = computed(() => { const userLocation = computed(() => { console.debug("new userLocation"); + if (noLocation.value) { + return { + lon: null, + lat: null, + name: null, + }; + } if (location.value) { console.debug("userLocation is typed location"); return addressToLocation(location.value); @@ -502,6 +511,10 @@ const performGeoLocation = () => { ); }; +const updateLocation = (newlocation: IAddress | null) => { + noLocation.value = newlocation == null; +}; + /** * View Head */