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

Error occurred when press enter on an empty list #75

Open
bonilka opened this issue Mar 25, 2018 · 4 comments
Open

Error occurred when press enter on an empty list #75

bonilka opened this issue Mar 25, 2018 · 4 comments
Labels

Comments

@bonilka
Copy link

bonilka commented Mar 25, 2018

Step for reproducing:
1.enter long string (no autocomplete values);
2.press the enter key;
result: error in console
@browser_2018-03-25_16-54-23

@BosNaufal BosNaufal added the bug label Jul 18, 2018
@scripta55
Copy link

i am also looking for a way to handle this, or an option to load a url at this point

@MimonCopitman
Copy link

I'm having the same problem here.

@Floriskoch
Copy link

For anyone reading this, I had the same problem: I forked the repo and changed line vue-autocomplete.vue:244 into this this.json.length ? this.selectList(this.json[this.focusList]) : e.target.form.submit(). This was sufficient for my use case, but otherwise you could hook it up to another method.

@edwh
Copy link

edwh commented Aug 6, 2019

Another possible way to work around this is to attach a listener to the input and suppress the enter key in appropriate circumstances.

  mounted() {
    const input = this.$refs.autocomplete.$refs.input
    input.addEventListener('keydown', this.suppressEnter, false)
  },
  methods: {
    suppressEnter(e) {
      // Enter when there are no results breaks things.  This is a bug in the plugin, but this works around it.
      if (e.which === 13 && this.results.length === 0) {
        e.preventDefault()
        return false
      }
    },

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

No branches or pull requests

6 participants