Ngx-bootstrap: Typeahead throws an exception when no option is selected

Created on 28 Apr 2020  路  8Comments  路  Source: valor-software/ngx-bootstrap

ERROR TypeError: Cannot read property 'length' of undefined
at TypeaheadDirective.onBlur (ngx-bootstrap-typeahead.js:2010)
at TypeaheadDirective_blur_HostBindingHandler (ngx-bootstrap-typeahead.js:2394)
at executeListenerWithErrorHandling (core.js:21693)
at wrapListenerIn_markDirtyAndPreventDefault (core.js:21742)
at HTMLInputElement. (platform-browser.js:934)
at ZoneDelegate.invokeTask (zone-evergreen.js:399)
at Object.onInvokeTask (core.js:41344)
at ZoneDelegate.invokeTask (zone-evergreen.js:398)
at Zone.runTask (zone-evergreen.js:167)
at ZoneTask.invokeTask [as invoke] (zone-evergreen.js:480)

Most helpful comment

@daniloff200 I'm also experiencing this issue. If you try the Async Data example from the docs pages (Async Example) it occurs there (the stackblitz examples fail to load core-js for me for some reason). To Reproduce:

  1. Place focus in the text field
  2. Do not type anything
  3. Blur the control by going to some other element

In the console you should see the stack trace defined above. In digging a little deeper, the _matches object in onBlur is undefined, thus leading to this error.

All 8 comments

hello, @vindiezel23
Could you provide a small demo (Stackblitz) or github repo with your code, when I can reproduce that issue?

That's hard to understand, what's going on here.

I have thoughts, that you doesn't provided a data in model, but, that just a guess

@daniloff200 I'm also experiencing this issue. If you try the Async Data example from the docs pages (Async Example) it occurs there (the stackblitz examples fail to load core-js for me for some reason). To Reproduce:

  1. Place focus in the text field
  2. Do not type anything
  3. Blur the control by going to some other element

In the console you should see the stack trace defined above. In digging a little deeper, the _matches object in onBlur is undefined, thus leading to this error.

@daniloff200 I'm also experiencing the same issue. Exception is being logged in the console when you blur from the input text field without doing anything

I remember that

  • I didn't experience these issues on a page with a single typeahead Input but
  • i experienced this on a page with two typeahead inputs.

There have probably been more possible influences in the environment where I tested it. But I am not on a computer right now so I can't create a demo to prove the above described case.

This is the same as issue #5736 where I added a Stackblitz @daniloff200
https://github.com/valor-software/ngx-bootstrap/issues/5736#issuecomment-611026305

A pull request was created 25 days ago now, but has not been touched since.

Any update on this?

It seems it takes quite a long time. Not too much code in pull request but still not touched.
Hopefully it can be merged soon.

fixed in 6.0.0

Was this page helpful?
0 / 5 - 0 ratings