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

Current value doesn't reset after redirect #227

Open
zhukovsergei opened this issue Mar 16, 2022 · 2 comments
Open

Current value doesn't reset after redirect #227

zhukovsergei opened this issue Mar 16, 2022 · 2 comments

Comments

@zhukovsergei
Copy link

  • vue-autosuggest version:
  • node version: v17.4.0
  • npm (or yarn) version: 8.3.1

Relevant code or config

<vue-autosuggest
    v-model="currentValue"
    :suggestions="suggestions"
    :input-props="{id:'autosuggest__input', placeholder:'Task ID'}"
    @input="onInputSuggestChange"
    @selected="handleSelectedTask"
>
    <template v-slot="{suggestion}">
        <span class="my-suggestion-item">{{suggestion.item}}</span>
    </template>
</vue-autosuggest>
        handleSelectedTask(selectedItem) {

            if(parseInt(router.currentRoute.params.id) === parseInt(selectedItem.item)) {
                return;
            }else {
                router.push({ name: 'nummer', params: { id: selectedItem.item } });
            }

            this.$nextTick(() => {
                this.currentValue = '';
            });
        },

What you did:
I'm select the value and success redirect.

What happened:
After first redirect current value is reset. OK

Problem description:
When i'm search the second or the third times, i'm successfully redirected BUT clean current field doesn't work.
VUE debugger shows this.currentValue is empty. But on the render i'm still see it:

image

Any ideas?

@brian-izaki
Copy link

brian-izaki commented Apr 28, 2022

this issue help you? #156

@Aryan3212
Copy link

Aryan3212 commented Feb 9, 2023

<vue-autosuggest
            :key="4"

Add a key prop to your vue-autosuggest instances, looked everywhere and this finally seems to work. This is added to the documentation but it doesn't stand out.

Code demo here: https://codesandbox.io/s/vueautosuggest-multiple-vue-autosuggests-545ee?file=/AutosuggestInstance.vue

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

3 participants