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 Multiple model become empty string when delete digits #7161

Closed
ghost opened this issue Jan 22, 2019 · 1 comment
Closed

Autocomplete Multiple model become empty string when delete digits #7161

ghost opened this issue Jan 22, 2019 · 1 comment
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@ghost
Copy link

ghost commented Jan 22, 2019

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)
https://stackblitz.com/edit/angular-f7xluh

Current behavior
On a multiple autocomplete, If i add some value, and start typing a new on and delete all of my digits (so the input value become an empty string), the model/form control become an empty string

Expected behavior
The model/form control should be the list of value previously selected.

Minimal reproduction of the problem with instructions
Type 'a' and select Afghanistan, type 'b' and select Bahamas, type 'c' and backspace to delete.

What is the motivation / use case for changing the behavior?
It's a problem.
I think the error is on src/app/components/autocomplete/autocomplete.ts on line 333

this code
this.onModelChange(value);

should become
if (!this.multiple) this.onModelChange(value);

otherwise the model of multiple autocomplite become empty string and lose the previous values.

  • Angular version: 7.0

  • PrimeNG version: ^7.0.4

  • Browser: all

  • Language: all

  • Node (for AoT issues): 1.6.0

@kylebake
Copy link

I've been pulling my hair out with this all day. Found a workaround by modifying this line (line 161) here in primeng/components/autocomplete/autocomplete.js:

if (value.length === 0) {

becomes:

if (value.length === 0 && !this.multiple) {

@cagataycivici cagataycivici self-assigned this Feb 28, 2019
cagataycivici added a commit that referenced this issue Feb 28, 2019
…ut-clear-fix

Fixed #7161. Autocomplete multiple input clearing entire model
@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Feb 28, 2019
@cagataycivici cagataycivici added this to the 7.1.0 milestone Feb 28, 2019
darkhelmet pushed a commit to weknowtraining/primeng that referenced this issue Mar 25, 2019
…ocomplete to ensure that multiple mode is not active before emitting the model change when the value is an empty string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

2 participants