Primeng: Autocomplete clears selected item on blur

Created on 8 Oct 2020  路  9Comments  路  Source: primefaces/primeng

I'm submitting a ... (check one with "x")

[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

Current behavior
If user picks item by pressing enter and [forceSelection]="true", the selected item is cleared on blur event.

Expected behavior
The selected item should not be cleared.

pending-review

Most helpful comment

I'm curently working on a project that have too many autocompletes, making the workaround unviable.
Any news about fixing this bug?

All 9 comments

Workaround based on autocomplete showcase stackblitz:
html (added [forceSelection]="true" #autocomplete):

ts (added viewchild and AfterViewInit):

https://stackblitz.com/edit/primeng-autocomplete-demo-jmejyt?file=src/app/app.component.html

Thanks for workaround.

I am facing the same issue. Thanks, @cyprianno for the workaround.

Thanks, @cyprianno! For posterity and convenience, I'm copying the workaround to the issue's comments:

  1. Assign a template reference variable to the affected <p-autoComplete>:

    <p-autoComplete #autocomplete ...>
    
  2. Get a reference to the component in the code:

    @ViewChild('autocomplete') autocomplete: AutoComplete;
    
  3. In ngAfterViewInit, erase one of its event handlers:

    ngAfterViewInit() {
      this.autocomplete.onOverlayAnimationDone = (event) => {};
    }
    

I'm curently working on a project that have too many autocompletes, making the workaround unviable.
Any news about fixing this bug?

We have the same problem, the worst of it is that we have more than 10000 autocompletes in the application, the palliative solution does not help us

I hope that this bug gets fixed soon. We are also using more than few autocompletes.

It is fixed in 11.0.0 (and LTS) with fixing issue #8740

Thanks, closing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KannanMuruganmony picture KannanMuruganmony  路  3Comments

lilling picture lilling  路  3Comments

jisqaqov picture jisqaqov  路  3Comments

philly-vanilly picture philly-vanilly  路  3Comments

gatapia picture gatapia  路  3Comments