ng2-completer
ng2-completer copied to clipboard
focus event is not working
Let begin with saying, I love this module. and thank you for your work.
I have tried to use onFocus event as mentionned in the example. ` <ng2-completer
#myAutocomplete
[datasource]="'https://raw.githubusercontent.com/oferh/ng2-completer/master/demo/res/data/colors.json?'" [minSearchLength]="1" [placeholder]="'search color'" [inputClass]="'form-control'" (focus)="focused = true; blurred = false;" (blur)="focused = false; blurred = true;" [fillHighlighted]="false" (selected)="onCountrySelected($event)" [textSearching]="'Please wait...'" [autofocus]='true'> `
But It did'nt work for me. I am asking if there's something special I have to do to make it work ?
- And also, I have another problem. In fact, when I do select a proposition from the dropdown list, the input element is on focus. how can I force the input to blur. I mean there are methods to manipulate the autocomplete such as close() and open() and focus(). But how can we force it to blur after I select a proposition.
Here's my code :
@ViewChild("myAutocomplete") private myAutocomplete : CompleterCmp;
and then
onSelected(selected: any): void { console.log('my element', this.myAutocomplete); /*and here i try to blur my input*/ this.lifeAutocomplete.close(); this.renderer.invokeElementMethod(this.myAutocomplete, 'blur'); }
Thank you.
@AsmaGargouri thanks!
about the focus can you provide the code for what you tried to do on focus/blur?
you can switch the focus to another element in selected
event.
In fact, Even when I force to focus on another element after selecting item from dropdown list, I got the input focus just after that. I don't know why
@AsmaGargouri if you can provide a plunker sample it can really help understand the issue
Hey oferh, I have the same issue as Asma. The focus event is not firing : I just put the event in the ng2-completer div : (focus)='onAreaFocus($event)' But the component's onAreaFocus function is not called when I click in the input. It's weird beacause the selected event works great.
Do you have any idea? Thanks!
@valentinbdv can you create a plunker that reproduces the issue, the demo seems to be working ok
Hi , I am working with ng2-completer . It's working great but it selects the input on losing focus from the input field also. can anyone please help me to resolve the issue ASAP. Thank you in advance!!