Primeng: Add completeOnFocus option to AutoComplete

Created on 18 Sep 2017  路  12Comments  路  Source: primefaces/primeng

I'm submitting a bug

[ x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

This behavior was working as expected in version 4.1.2 since 4.2.0 (i dont know the exact version when it stopped showing list of suggestions);

Current behavior
When input has focus(don't typing any character inside input field), list of items don't show

Expected behavior
List of suggestions should show on focus.

new feature

Most helpful comment

I am using the folllowing workaround to display the selection on focus when there is no value selected:

<p-autoComplete ... (onFocus)="!autocomplete.value && autocomplete.handleDropdownClick()" dropdownMode="current" #autocomplete>
</p-autoComplete>

All 12 comments

This just started happening in our app as well.

Why should they show up on focus anyway without no typing?

List of suggestions should show on focus.

+100

@cagataycivici in our case we preload some values when loading the view, so if you focus you already see a list of suggestions available but we can return more values if you start typing. It is just to make the user life easier.

So there is no way with the current release to make that?

I am using the folllowing workaround to display the selection on focus when there is no value selected:

<p-autoComplete ... (onFocus)="!autocomplete.value && autocomplete.handleDropdownClick()" dropdownMode="current" #autocomplete>
</p-autoComplete>

@cagataycivici From the user perspective I believe this behavior is useful for previewing what kind of data can be queried and returned, and also for immediate feedback that specific field has a different behavior and it is not a generic text input where it can enter any value.

Hi, This solved for me
<p-autoComplete ... (onFocus)="autocomplete.show()"> </p-autoComplete>

Still looking forward any updates on this issue.

As @dinhani described, the workaround works on the first click on the input field. Once the selected item is cleared, this method will be no more valid. Here is my workaround to display the list also after clearing the selected item:

<p-autoComplete ...
    (onFocus)="!autocomplete.value && autocomplete.handleDropdownClick()"
    (onClear)="clearItem(autocomplete)" #autocomplete>
</p-autoComplete>

then implement the function clearItem() in component:

clearItem(autocomplete: any) {
    autocomplete.value = '';  
    autocomplete.handleDropdownClick();  
}  

Will add showOnFocus targeting 9.0.2

Added "completeOnFocus" property, defaults to false.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Helayxa picture Helayxa  路  3Comments

just-paja picture just-paja  路  3Comments

pchristou picture pchristou  路  3Comments

miresk picture miresk  路  3Comments

cyberrranger picture cyberrranger  路  3Comments