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 Clear Icon not shown if value set programatically #16410

Open
gianluca-moro opened this issue Sep 20, 2024 · 1 comment
Open

Autocomplete Clear Icon not shown if value set programatically #16410

gianluca-moro opened this issue Sep 20, 2024 · 1 comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@gianluca-moro
Copy link

Describe the bug

When setting the value of a p-autocomplete with [showClear]="true" programatically in the Typescript class, the clear icon is not shown even though the value is present. Only when clicking into the Autocomplete, the clear icon is shown and stays shown when leaving the input again.

Environment

  • Primeng v17.18.9
  • Angular v18.2.3

Reproducer

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

Angular version

18.2.3

PrimeNG version

17.18.9

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

18.19.1

Browser(s)

Chrome, Firefox

Steps to reproduce the behavior

  1. Run the Stackblitz application https://stackblitz.com/edit/s5gxpn?file=src%2Fapp%2Fautocomplete-dropdown-demo.ts
  2. Voila, the autocomplete has a value present but no clear icon even though [showClear]="true" is set
<p-autoComplete
    formControlName="country"
    [dropdown]="true"
    [suggestions]="filteredCountries"
    (completeMethod)="filterCountry($event)"
    field="name"
    [showClear]="true"
  />
ngOnInit() {
    this.countryService.getCountries().then((countries) => {
      this.countries = countries;
    });
    this.formGroup = this.formBuilder.group({
      country: [{ name: 'Afghanistan', code: 'AF' }],
    });
  }

Expected behavior

The clear button should be visible whenever a value is present, even if the value is set programatically in the typescript class.

@gianluca-moro gianluca-moro added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Sep 20, 2024
@gianluca-moro
Copy link
Author

And please don't tell me this is intended behaviour because now the user has to first click into the input and then hit the clear button instead of only needing a single click on the clear button.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests

1 participant