Skip to content

Use Ref focus then it can not suggest #591

@greeenSY

Description

@greeenSY

I'm submitting a ...

  • bug report
  • feature request
  • support request

What is the current behavior?

I emit a focus event, then it errors when suggest.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

<template>
   <vue-simple-suggest
              v-if="emailInputVisible"
              ref="emailInput"
              type="text"
              size="small"
              v-model="emailInputValue"
              :list="suggestedEmailList"
              :style="{ width: '240px', height: '25px', marginRight: '8px', display: 'inline-block' }"
              autocomplete="off"
              :filter-by-query="true"
          >
          </vue-simple-suggest>
          <a-tag v-else style="background: #fff; borderStyle: dashed;" @click="showEmailInput">
            <a-icon type="plus"/>
          </a-tag>
</template>

<script>
export default {
  //...
  
  data() {
    emailInputValue: '',
    suggestedEmailList: []
  }
  methods: {
    showEmailInput() {
      this.emailInputVisible = true
      this.$nextTick(function () {
         this.$refs.emailInput.$el.querySelector('input').focus() // it encountered this error?
      })
    },
  }
  //...
}
</script>

What is the expected behavior?

How are you importing Vue-simple-suggest?

  • ESNext (original code, single-file .vue component, css included) (import VueSimpleSuggest from 'vue-simple-suggest/lib')
  • ES6 (import VueSimpleSuggest from 'vue-simple-suggest')
  • ES7 and above (import VueSimpleSuggest from 'vue-simple-suggest/dist/es7')
  • Bundled version (import VueSimpleSuggest from 'vue-simple-suggest')
  • CommonJS (const VueSimpleSuggest = require('vue-simple-suggest'))
  • UMD Component (<script type="text/javascript" src="https://unpkg.com/vue-simple-suggest"></script>)

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • Vue.js Version: 2.6.10
  • Vue-simple-suggest version: 1.11.2
  • Browser: Chrome
  • Language: ES6
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions