Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.

Missing reactivity #132

Open
alexander-feil opened this issue Feb 14, 2019 · 2 comments
Open

Missing reactivity #132

alexander-feil opened this issue Feb 14, 2019 · 2 comments

Comments

@alexander-feil
Copy link
Contributor

Hey,

I have a use case, where I would want to set the default value in the mounted() method.
If I try this with the Demo, the input field stays empty.

I think it should be possible...
What do you think?

Bye

@lino
Copy link

lino commented Mar 10, 2019

Could you please submit the code you're trying to use? Setting the default value in mount() has some implications in vue.js.

@Kocal
Copy link
Owner

Kocal commented Mar 11, 2019

Hum, thanks for bumping the issue, I totally forgot about this one. 😅

I think it's because the prop input (<vuetify-algolia-places v-model="place"> or <vuetify-algolia-places :input="place"> is only read when building component's data:

data() {
// The initial value can be a string or an object
// eslint-disable-next-line no-nested-ternary
const initialValue = this.value ? (typeof this.value === 'string' ? this.value : this.value.value) : null;
const initialPlace = { value: initialValue };
return {
loading: false,
query: initialValue,
place: initialPlace,
places: initialValue ? [initialPlace] : [],
filter() {
return true; // display all items, Algolia Places is already doing the work
},
};

Maybe if we add a watcher on input props like we did for query data, it may probably works:

query(val) {
if (val) {
this.searchPlaces();
}
},

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants