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

typeahead-callback doesn't show autocomplete prompts #149

Open
Creling opened this issue Jun 30, 2021 · 3 comments
Open

typeahead-callback doesn't show autocomplete prompts #149

Creling opened this issue Jun 30, 2021 · 3 comments

Comments

@Creling
Copy link

Creling commented Jun 30, 2021

I use "@voerro/vue-tagsinput": "^2.7.1" in my "vue": "^2.6.11" proj to find that typeahead-callback doesn't show autocomplete prompts.

Some code snippets are as follows:

<el-col :span="20" style="margin: auto">
  <tags-input
    element-id="tags"
    v-model="selectedTags"
    :existing-tags="existingTags"
    :typeahead="true"
    :typeahead-callback="search_tags"
    @tag-added="on_tag_added"
    @tag-removed="on_tag_removed"
    :add-tags-on-comma="true"
    :delete-on-backspace="true"
    typeahead-style="badges"
    value-fields="value"
  ></tags-input>
</el-col>
search_tags(query) {
  console.log(query);
  return new Promise((resolve) => {
    this.$axios
      .get( ... )
      .then((res) => {
        let result = [];
        for (let key in res.data) {
          result.push({ key: key, value: res.data[key] });
        }
        console.log(result);
        resolve(result);
      });
  });
},

I notice that console.log(result); prints correct results but no autocomplete prompts are shown.

Any help is appreciated :)

Creling

@elmage
Copy link

elmage commented Jul 3, 2021

I have the same problem.
Looking for an alternative package now.

@peinkofer
Copy link

peinkofer commented Jul 10, 2021

I had the same problem. In VoerrorTagsInput.vue,

if (this.typeaheadCallback) { this.typeaheadCallback(searchQuery) .then((results) => { this.typeaheadTags = results; }); }

has to be changed to this:

if (this.typeaheadCallback) { this.typeaheadCallback(searchQuery) .then((results) => { this.typeaheadTags = results; this.doSearch(searchQuery); }); }

Then it works for me. And seems there is already a PR open for this: https://github.com/voerro/vue-tagsinput/pull/147/commits

@hodbn
Copy link

hodbn commented Jul 26, 2021

As another workaround until the PR is merged, you can add a ref to the components (e.g. ref="tagsinput") and then call doSearch after resolving the promise.

autocomplete(q) {
  const p = this.searchRemoteServer({ query: q })
  return new Promise((resolve) => {
    p.then((results) => {
      resolve(results)
      this.$refs.tagsinput.doSearch(q)
    })
  })
},

Ivolutio added a commit to MetaChef/vue-tagsinput that referenced this issue Jul 8, 2022
As described in this issue in the original repository: voerro#149 (comment)
Would be nice to be able to use your repository for now.
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

4 participants