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

Fix(typeahead): show available choices onFocus when minLength == 0 #1919

Closed

Conversation

tzielins
Copy link

Fixes #1559

Currently typeahead does not show list on focus when typeaheadMinLength="0" even is such behaviour is documented.

onFocus method is comparing minLength with 0, while the angular sets input property to string '0' and no event is emitted.

Fixed the issue by replacing === with == in the comparison.

@codecov
Copy link

codecov bot commented Apr 19, 2017

Codecov Report

Merging #1919 into development will increase coverage by 0.14%.
The diff coverage is 100%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development    #1919      +/-   ##
===============================================
+ Coverage        85.93%   86.08%   +0.14%     
===============================================
  Files               78       78              
  Lines             2098     2098              
  Branches           273      273              
===============================================
+ Hits              1803     1806       +3     
+ Misses             202      200       -2     
+ Partials            93       92       -1
Impacted Files Coverage Δ
src/typeahead/typeahead.directive.ts 77.96% <100%> (+1.69%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 60fe034...6fe09df. Read the comment docs.

@arun-haridas
Copy link
Contributor

Guys , this issue is fixed or what??

@renaud-dev
Copy link

renaud-dev commented Jun 20, 2017

Hello,
For people looking for a temporary fix, you can add square brackets arroud typeaheadMinLength :

<form [formGroup]="myForm">
  <input formControlName="state"
         [typeahead]="states"
         [typeaheadMinLength]="0">
</form>

(angular 4.0.3 & ngx-bootstrap 1.6.6)

EDIT : contrary to what @dasdecoder pretends below, it works (confirmed by @tzielins). It makes typeaheadMinLength a basic regular Angular Input (taking advantage of template compilation, typing, etc...).

@arun-haridas
Copy link
Contributor

@renaudaste I tried [typeaheadMinLength]="0" instead of typeaheadMinLength="0" , but still i'am having the same issue ...!! Please help me to find a workaround.

@tzielins
Copy link
Author

tzielins commented Jul 3, 2017

@dasdecoder the [] trick works but you can also force the value to be 0 by declaring a numerical variable in your component with 0 value and reference it from the template, for example [typeaheadMinLength]="zero"

@valorkin
Copy link
Member

Guys, it is not a trick. It works as expected
rather documentation should be updated
[typeaheadMinLength]="0" is completely correct behavior
typeaheadMinLength="0" is setting a string to numeric field,
it should not happen

Thanks for PR

@valorkin valorkin closed this Jul 18, 2017
@arun-haridas
Copy link
Contributor

@valorkin , @tzielins , @renaudaste unfortunately none of the above mentioned solutions worked for me. I added @HostListener('click') listener in TypeaheadDirective.ts and it started responding the way i need . I am not sure that it's the correct way of solving the issue. Please correct me if am doing wrong...

arun-haridas pushed a commit to arun-haridas/ngx-bootstrap that referenced this pull request Jul 29, 2017
Workaround for the issue valor-software#1919  (typeahead): show available choices onFocus when minLength == 0
valorkin pushed a commit that referenced this pull request Oct 13, 2017
Workaround for the issue #1919  (typeahead): show available choices onFocus when minLength == 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants