Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When I have a value binded, if I reset the value the component isn't updated #161

Open
fshahmt opened this issue Feb 21, 2023 · 1 comment

Comments

@fshahmt
Copy link

fshahmt commented Feb 21, 2023

<autocomplete :search="searchArea" required placeholder="Search and select" aria-label="Search and select" class="hard-skills" :get-result-value="getResultValue" @submit="setSecondaryAreaForUser" v-bind:default-value="userDetails.secondaryArea" ></autocomplete>

This is the markup for the code.

When I select a new value in the other select (this one is basically a dependant), I reset the userDetails.secondaryArea value to null but it still has the old value.

This is definitely not the expected behaviour.

<div class="form-group text-left" @change="reset('institution')"> <label>Your educational institution? *</label> <select class="form-control text-secondary" v-model="userDetails.institution" @change="getCurrentUniversityData()" required > <option value="null" disabled v-if="universities.universities.length !== 1" > Select from list </option> <option v-for="(institute, index) in universities.universities" :key="index" :value="{ uid: institute.id, id: institute.university_id, name: institute.university_name, }" > {{ institute.university_name }} </option> </select> </div> <div class="form-group text-left" > <label>Your study degree *</label> <autocomplete :search="searchArea" required placeholder="Search and select" aria-label="Search and select" class="hard-skills" :get-result-value="getResultValue" @submit="setAreaForUser" v-bind:default-value="userDetails.area" ></autocomplete> </div>

This is the minimal code you can test it with, just add whatever script long as you get the same results

@KonRatt
Copy link

KonRatt commented Feb 28, 2024

The default-value prop is not reactive and is only used during creation. One hacky way would be to force the recreation of the component by using Vues key attribute.

<autocomplete
    :key="userDetails.secondaryArea"
    :search="searchArea"
    :get-result-value="getResultValue"
    @submit="setSecondaryAreaForUser"
    :default-value="userDetails.secondaryArea"
/>

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

No branches or pull requests

2 participants