ng2-completer icon indicating copy to clipboard operation
ng2-completer copied to clipboard

focus event is not working

Open AsmaGargouri opened this issue 7 years ago • 6 comments

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 avatar Apr 05 '17 08:04 AsmaGargouri

@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.

oferh avatar Apr 06 '17 10:04 oferh

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 avatar Apr 18 '17 15:04 AsmaGargouri

@AsmaGargouri if you can provide a plunker sample it can really help understand the issue

oferh avatar Apr 18 '17 19:04 oferh

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 avatar Jul 26 '17 14:07 valentinbdv

@valentinbdv can you create a plunker that reproduces the issue, the demo seems to be working ok

oferh avatar Aug 11 '17 08:08 oferh

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!!

ShubhK avatar May 10 '18 07:05 ShubhK