AbsaOSS / cps-shared-ui

Angular shared components library
https://absaoss.github.io/cps-shared-ui/
Apache License 2.0
2 stars 2 forks source link

Autocomplete input value is reset on page scroll/on blur #378

Closed lukasmatta closed 5 months ago

lukasmatta commented 5 months ago

Behavior of the autocomplete component is a bit confusing. When user clicks out of the input or scrolls page, the value in the input is reset. I find it especially confusing with fetched options, as the following scenario might happen:

  1. User types a value to input.
  2. Options are fetched based on the value.
  3. User scrolls page.
  4. Input value is reset, but the options stay the same, as the function that is fetching options usually doesn't do so if the value is empty string*.

How to reproduce.

  1. Go to https://absaoss.github.io/cps-shared-ui/autocomplete/examples.
  2. Type "Pr" into the Single search autocomplete with fetched options list autocomplete.
  3. Scroll the page or click somewhere out of the input.
  4. Click on the input.
  5. Options stays set to "Prague" as this is the only option satisfying the "Pr" string, but the "Pr" string is not in the input anymore.

*The solution might be to simply reset options when the input value is empty string instead of returning and doing nothing, but I still find resetting input value on scroll/on blur unexpected.