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

Typeahead treats 0 as a null value #2389

Closed
ronantreacy opened this issue May 21, 2018 · 3 comments
Closed

Typeahead treats 0 as a null value #2389

ronantreacy opened this issue May 21, 2018 · 3 comments

Comments

@ronantreacy
Copy link

ronantreacy commented May 21, 2018

Bug description:

If 0 (zero) is passed as a model value to the typeahead formatter it is returned as a string rather than being formatted. In my example the formatting function checks whether an object with an id matching the input exists in an array and if so returns the object name. 0 is a valid input but as 0 is falsy the typeahead _formatItemForInput function returns the input as a string.

Link to minimally-working plunker that reproduces the issue:

http://plnkr.co/edit/NHCHep7OuiceRi0rRdAa?p=preview

Version of Angular, ng-bootstrap, and Bootstrap:

Angular: 5.0.2

ng-bootstrap: 1.1.2

Bootstrap: 4.0.0

@pkozlowski-opensource
Copy link
Member

Oh, right! This should be an easy fix here:

return item && this.inputFormatter ? this.inputFormatter(item) : toString(item);

Would you be up to sending a PR? We would merge it if it comes with a test, follows our guidelines etc. Relevant reading: https://github.com/ng-bootstrap/ng-bootstrap/wiki/Contributions%3A-How-to-get-a-PR-merged-fast%3F

@pkozlowski-opensource
Copy link
Member

Never mind, I've sent #2399 to fix this issue.

@ronantreacy
Copy link
Author

@pkozlowski-opensource Fast work, was going to have a look this evening but you beat me to it. Looks good.

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

No branches or pull requests

2 participants