primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Multiselect Autocomplete not displaying previous selections until receiving focus

Open BartokW opened this issue 6 years ago • 5 comments

If you have a PrimeNG PRO Support subscription please post your issue at;

https://pro.primefaces.org

where our team will respond within 4 business hours.

If you do not have a PrimeNG PRO Support subscription, fill-in the report below. Please note that your issue will be added to the waiting list of community issues and will be reviewed on a first-come first-serve basis, as a result, the support team is unable to guarantee a specific schedule on when it will be reviewed. Thank you for your understanding.

Current Queue Time for Review Without PRO Support: ~8-12 weeks. With PRO Support: 1 hour

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

Plunkr Case (Bug Reports) Please demonstrate your case at stackblitz by using the issue template below. Issues without a test case have much less possibility to be reviewd in detail and assisted.

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

Current behavior

Pre-populating the variable that is bound to ngModel, causes the p-autocomplete control to still appear empty, until you click into it, at which point it displays the pre-populated selection

Expected behavior

Upon first displaying the control, show the pre-populated selection.

Minimal reproduction of the problem with instructions

Using the existing Autocomplete example, set the selectedCountries variable to have some countries already selected, and let it refresh. I modified the Stackblitz example here https://stackblitz.com/edit/primeng-autocomplete-demo-mouznf?file=src/app/app.component.ts

What is the motivation / use case for changing the behavior?

Want to be able to see what was previously selected when editing a form.

Please tell us about your environment:

  • Angular version: 10.0.1
  • PrimeNG version: 10.0.0
  • Browser: [al ]
  • Language: [TypeScript 3.9.5]

  • Node (for AoT issues): node --version =

BartokW avatar Sep 10 '20 15:09 BartokW

Even I am also facing the same issue. Try this snippet which is resolved my issue for the time being.

<p-autoComplete inputId="card-search-input" </p-autoComplete>

setTimeout(function () { let searchInput = document.getElementById("card-search-input"); if (searchInput) { searchInput.focus(); } }, 100);

noteme-io avatar Sep 11 '20 03:09 noteme-io

Any updates on this issue? That still happens Angular version: 10.0.1 PrimeNG version: 10.0.0 Browser: [al ] Language: [TypeScript 3.9.5]

olganosova2 avatar Oct 13 '20 01:10 olganosova2

In my case the p-autoComplete is within a p-tabView and my solution was to place an ngIf on the control for when the tab it is on becomes active/visible.

However, the difference in this case is that the pre-selected tags do render without needing the input to gain focus. So in this case it is not specifically a focus issue but some general rendering issue.

I ended up wrapping it with my own control and using *ngIf to hide/show the p-autoCompete on an incoming model in multiselect mode.

UPDATE: As I wrap p-autoComplete in my own component, if I rebind the model (e.g. a setTimeout with this.dropdownModel = _.cloneDeep(this.dropdownModel) ) on my own component incoming model, then it forces the re-render.

LukeHartcher avatar Oct 28 '20 22:10 LukeHartcher

Hi,

So sorry for the delayed response! Improvements have been made to many components recently, both in terms of performance and enhancement. Therefore, this improvement may have been developed in another issue ticket without realizing it. You can check this in the documentation. If there is no improvement on this, can you reopen the issue so we can include it in our roadmap? Please don't forget to add your feedback as a comment after reopening the issue. These will be taken into account by us and will contribute to the development of this feature. Thanks a lot for your understanding!

Best Regards,

mertsincan avatar Nov 09 '22 20:11 mertsincan

We are still facing this issue.

I've upgraded to 16.3.1 and the issue still persists.

I've noticed that we only really have our multi selects in modal dialog windows which are behind *ngIf statements as well. So perhaps it is something to do with that.

RickFrankel avatar Sep 21 '23 02:09 RickFrankel