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 does not display 0 as value #9628

Closed
Timmeeeey opened this issue Dec 8, 2020 · 1 comment
Closed

AutoComplete does not display 0 as value #9628

Timmeeeey opened this issue Dec 8, 2020 · 1 comment
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@Timmeeeey
Copy link

I'm submitting a ...

[x] bug report
[ ] feature request
[ ] support request

Plunkr Case (Bug Reports)
https://stackblitz.com/edit/primeng-autocomplete-demo-yvyemq

Current behavior
When using AutoComplete with objects and a numeric value then objects with value 0 are not displayed.
This is because 0 is a falsy value and therefore it is ignored in the first line of updateInputField().

updateInputField() {
  let formattedValue = this.value ? (this.field ? ObjectUtils.resolveFieldData(this.value, this.field)||'' : this.value) : '';
  ...
}

I solved this by replacing || with ??.

Expected behavior
When selecting an object with value 0 (e.g. { name: 'test', value: 0}) then 0 should be displayed.

  • Angular version: 11

  • PrimeNG version: 11

@yigitfindikli yigitfindikli added the Status: Pending Review Issue or pull request is being reviewed by Core Team label Dec 8, 2020
@yigitfindikli yigitfindikli self-assigned this Dec 8, 2020
@yigitfindikli yigitfindikli added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Pending Review Issue or pull request is being reviewed by Core Team labels Mar 11, 2021
@yigitfindikli yigitfindikli added this to the 11.3.1 milestone Mar 11, 2021
@yigitfindikli yigitfindikli added the LTS-PORTABLE Issue's fix will be ported to supported LTS versions label Mar 11, 2021
@Timmeeeey
Copy link
Author

@yigitfindikli
Unfortunately this doesn't work if an object with value 0 is preselected. I guess because updateInputField() has to be changed as well.
https://stackblitz.com/edit/primeng-autocomplete-demo-w4apqj

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

Successfully merging a pull request may close this issue.

2 participants