You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not at all familiar with using ngZone, but it seems like this change fixes it
autocomplete.ts/** Panel should hide itself when the option list is empty. */_setVisibility(){// Promise.resolve().then(() => this.showPanel = !!this.options.length);this.zone.run(()=>this.showPanel=!!this.options.length);}
The issue actually seems to be that clicking a button to focus the autocomplete triggers an _outsideClickStream event just after it has been opened, thus causing it to immediately close.
As a workaround, you can use a setTimeout to focus it after the outside click event fires.
Activity
willshowell commentedon Feb 23, 2017
I'm not at all familiar with using
ngZone
, but it seems like this change fixes itbergben commentedon Jun 6, 2017
Is there any workaround for this for now?
willshowell commentedon Jun 6, 2017
The issue actually seems to be that clicking a button to focus the autocomplete triggers an
_outsideClickStream
event just after it has been opened, thus causing it to immediately close.As a workaround, you can use a setTimeout to focus it after the outside click event fires.
http://plnkr.co/edit/cKYxnL9f8hV2Uklucd5d?p=preview
willshowell commentedon Jun 6, 2017
Alternatively use
stopPropagation()
on the click eventhttp://plnkr.co/edit/m4W7zAGulSaxhPqqlpzp?p=preview
willshowell commentedon Jul 24, 2017
Here's an updated plunker https://plnkr.co/edit/gyarTLKwyt97CX9304Fd?p=preview
bruteforce commentedon Sep 21, 2017
Below code did the trick for me assuming focus is already on input field.
mpolutta commentedon Apr 2, 2018
Combined willshowell and bruteforce solutions to solve for our 508 compliance scenario. Clear button is another scenario:
openAutoSearchPanel() {
if (this.searchText.length === 0) {
this.autoSearchInputTrigger._onChange('');
this.autoSearchInputTrigger.openPanel();
}
}
clearSearchText() {
console.log('>>> clearing searchText');
this.searchText = '';
/// hack: Another reported workaround - Allow the ClickStream to finish executing via setTimeout.
/// #3106
setTimeout(() => {
this.autoSearchInput.nativeElement.focus();
this.openAutoSearchPanel();
});
}
Charius commentedon Apr 28, 2018
yeah, got the same issue while implement custom field with autocomplete, timeout works, but this is pretty weird
maxterry commentedon Jul 13, 2018
Any update on this...?
tombolador commentedon Jul 31, 2018
+1, any updates?
mischkl commentedon Sep 17, 2018
This problem also affects chiplist inputs with autocomplete. 😢
31 remaining items