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

Errors produced when CTRL+X the text from the input field #131

Open
ruralcoder opened this issue Aug 31, 2021 · 1 comment
Open

Errors produced when CTRL+X the text from the input field #131

ruralcoder opened this issue Aug 31, 2021 · 1 comment

Comments

@ruralcoder
Copy link

Seems when you CUT the text out of the field it calls the API with a blank query
GET https://api.github.com/search/users?q= 422

Which then causes a bunch of errors

vue.runtime.esm.js?2b0e:619 [Vue warn]: Invalid prop: type check failed for prop "data". Expected Array, got Undefined 

found in

---> <VueTypeaheadBootstrap> at node_modules/vue-typeahead-bootstrap/src/components/VueTypeaheadBootstrap.vue
       <AutocompleteUsers>
         <CompanyEditor> at src/views/settings/CompanyEditor.vue
           <App> at src/App.vue
             <Root>

and

vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in render: "TypeError: Cannot read property 'length' of undefined"

found in

---> <VueTypeaheadBootstrap> at node_modules/vue-typeahead-bootstrap/src/components/VueTypeaheadBootstrap.vue
       <AutocompleteUsers>
         <CompanyEditor> at src/views/settings/CompanyEditor.vue
           <App> at src/App.vue
             <Root>

and

vue.runtime.esm.js?2b0e:1888 TypeError: Cannot read property 'length' of undefined
    at Proxy.render (VueTypeaheadBootstrap.vue?2251:13)
    at VueComponent.Vue._render (vue.runtime.esm.js?2b0e:3548)
    at VueComponent.updateComponent (vue.runtime.esm.js?2b0e:4066)
    at Watcher.get (vue.runtime.esm.js?2b0e:4479)
    at Watcher.run (vue.runtime.esm.js?2b0e:4554)
    at flushSchedulerQueue (vue.runtime.esm.js?2b0e:4310)
    at Array.eval (vue.runtime.esm.js?2b0e:1980)
    at flushCallbacks (vue.runtime.esm.js?2b0e:1906)
@slawkens
Copy link

I fixed this by checking length in the lookup method:

if (this.query.length < 3) {
    return;
}

Also short queries will be also ignored, so it won't spam server.

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

2 participants