Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete clears selected item on blur #9378

Closed
luboslav opened this issue Oct 8, 2020 · 11 comments
Closed

Autocomplete clears selected item on blur #9378

luboslav opened this issue Oct 8, 2020 · 11 comments
Assignees
Labels
Status: Pending Review Issue or pull request is being reviewed by Core Team

Comments

@luboslav
Copy link

luboslav commented Oct 8, 2020

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.

@cyprianno
Copy link

cyprianno commented Oct 12, 2020

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

@luboslav
Copy link
Author

Thanks for workaround.

@yashjangid1
Copy link

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

@Lx
Copy link

Lx commented Oct 20, 2020

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) => {};
    }

@picoloto
Copy link

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

@gasparbarancelli
Copy link

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

@luboslav
Copy link
Author

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

@meursj
Copy link

meursj commented Dec 11, 2020

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

@luboslav
Copy link
Author

Thanks, closing.

@ghost
Copy link

ghost commented Oct 13, 2022

I tried the solution, for me the autocomplete resolves to undefined

@lala81996
Copy link

The issue remains in V14.1.1. Unfortunately, the workaround doesn't work either since there seems to have been an update on onOverlayAnimationDone.

Would appreciate any suggestions or alternative workarounds ... Or even better an update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Pending Review Issue or pull request is being reviewed by Core Team
Projects
None yet
Development

No branches or pull requests

9 participants