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 is not working as expected #13026

Closed
denny99 opened this issue May 11, 2023 · 1 comment · Fixed by #13028
Closed

Autocomplete: Clear is not working as expected #13026

denny99 opened this issue May 11, 2023 · 1 comment · Fixed by #13028
Labels
LTS-FIXED-15.4.3 Fixed in PrimeNG LTS 15.4.3 LTS-PORTABLE Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@denny99
Copy link
Contributor

denny99 commented May 11, 2023

Describe the bug

When using the clear option in a single autocomplete, the clear button only clears the input not the actual value.

In multiple mode it clears the value.

This is quite confusing for the user as the autocomplete is obviously empty and therefore when saving anything, the value should be gone.

here is the code:

´´´js
clear() {
if (this.multiple) {
this.value = null;
}
else {
this.inputValue = null;
this.inputEL.nativeElement.value = '';
}
this.updateFilledState();
this.onModelChange(this.value);
this.onClear.emit();
}
```

In multiple mode the input won't be cleared, which is also wrong, as it is a different behaviour compared to the single mode.
And therefore it is incorrect to fire the onClear event, which states that the input was cleared and thats not the case

Environment

Doesn't matter

Reproducer

https://stackblitz.com/edit/github-sx74zq?file=src/app/app.component.ts

Angular version

15.x

PrimeNG version

15.4.1

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

16.x

Browser(s)

No response

Steps to reproduce the behavior

  1. Visit the reproducer
  2. Select a Value in the AC
  3. Clear the Value
  4. Press the Button. It will still show the previous selected value

Expected behavior

Clear should also clear the value of the ac

@denny99 denny99 added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label May 11, 2023
@denny99
Copy link
Contributor Author

denny99 commented May 11, 2023

Maybe duplicate to #12729

denny99 pushed a commit to denny99/primeng that referenced this issue May 11, 2023
@cetincakiroglu cetincakiroglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels May 16, 2023
@cetincakiroglu cetincakiroglu added this to the 16.0.0 milestone May 16, 2023
cetincakiroglu added a commit that referenced this issue May 18, 2023
fix(autocomplete): #13026 clear working properly in single mode
@gucal gucal added the LTS-FIXED-15.4.3 Fixed in PrimeNG LTS 15.4.3 label May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTS-FIXED-15.4.3 Fixed in PrimeNG LTS 15.4.3 LTS-PORTABLE Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants