primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Autocomplete: Single autocomplete doesn't reset value of component picked by keyboard when calling formGroup reset

Open kkoripl opened this issue 3 years ago • 1 comments

Describe the bug

When navigating in dropdown only by keyboard and picking value also only by it (enter) and then immediately, without any other actions, we'll reset form (by button click with mouse) which dropdown value is saved to, picked item is cleared for a second and then restored.

Clicking the dropdown item to select, instead of picking it by enter, makes everything working alright. There can be a possibility, that blur event is setting the value once again after reset, because it's being invoked after reset button is clicked in the bug scenario. When we click item to be selected in dropdown, blur event is called immediately.

Environment

OS: Windows 10 / MAC

Reproducer

https://stackblitz.com/edit/stackblitz-starters-esf7da?file=src%2Fapp%2Fdemo%2Fautocomplete-dropdown-demo.ts

Angular version

16.2.8

PrimeNG version

16.6.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

18.6.0+

Browser(s)

No response

Steps to reproduce the behavior

IMPROTANT: Do not do anything between points 3 and 4 just grab your mouse after selection, move it to button and click. No tabs, no losing focus on dropdown, no clicking wherever else.

  1. Open stackblitz example
  2. Start typing to select any country (3 letters needed to see suggested options).
  3. Only by keyboard (important!) pick a country, so use arrows to go to country and then use enter to select it.
  4. Click reset button with mouse.

Result: Name of selected country will be gone for a second and will come back. Control value below will be nullified just to being set once again to picked country.

Expected behavior

Name of selected country will be cleared as well as control value below it.

One small note, I've made a hack method inside the stackblitz example, if it's connected to primeNg autocomplete component by (onKeyUp) method, then whole thing works well.

kkoripl avatar Nov 09 '23 08:11 kkoripl

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 Dec 04 '24 11:12 mertsincan