KazanExpress / vue-simple-suggest

Feature-rich autocomplete component for Vue.js
https://kazanexpress.github.io/vue-simple-suggest/
MIT License
461 stars 74 forks source link

Support for <textarea> #94

Open nattam opened 6 years ago

nattam commented 6 years ago

I'm submitting a ...

I use vue-simple-suggest with a Dadate. Addresses are usually quite long. And the input field does not always fit the entire address. Especially on mobile devices. It would be great to add a setting for field type input or textarea.

Example:

suggests

Raiondesu commented 5 years ago

Hello, @nattam. Sorry for taking so long to respond.

This feature request is not particularly easy to implement with current realization of the component.

We'll schedule it for the v2.0 that is coming 2019 with the release of Vue.js v3.0.

Right now, however, you can emulate the support for textarea by doing something like this:

<vue-simple-suggest>
  <div class="wrapper">
    <input type="hidden" style="display:none" v-model="inputText"/>
    <textarea v-model="inputText"></textarea>
  </div>
</vue-simple-suggest>

This way, you'll have a hidden input that successfully duplicates everything you type into the textarea, so vue-simple-suggest can react to the changes in your text.

Raiondesu commented 5 years ago

For people that come here looking for the solution - remember that you can always extend any component to change its functionality, like so:

import VueSimpleSuggest from 'vue-simple-suggest'

export default {
  extends: VueSimpleSuggest,
  mounted () {
    this.inputElement = this.$refs['inputSlot'].querySelector('textarea')
    this.prepareEventHandlers(true)
  }
}

This will certainly solve problems.

Raiondesu commented 5 years ago

For anyone who could possibly implement support for

Chosen element: {{ chosen }}

import VueSimpleSuggest from 'vue-simple-suggest'

export default { components: { VueSimpleSuggest }, extends: VueSimpleSuggest, mounted () { this.inputElement = this.$refs.search.querySelector('textarea') this.prepareEventHandlers(true) }, data() { return { chosen: '' } }, methods: { simpleSuggestionList() { return [ 'Vue.js', 'React.js', 'Angular.js' ] } } }

Sorry but is the first time for me in VUE.