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 when preselected #10031

Closed
Timmeeeey opened this issue Mar 23, 2021 · 1 comment
Closed

AutoComplete does not display 0 as value when preselected #10031

Timmeeeey opened this issue Mar 23, 2021 · 1 comment
Assignees
Labels
LTS-FIXED-9.2.6 Fixed in PrimeNG LTS 9.2.6 LTS-FIXED-10.1.1 Fixed in PrimeNG LTS 10.1.1 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-w4apqj

Current behavior
When using AutoComplete with objects and a numeric value then objects with value 0 are not displayed when preselected.
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 ??.

This is related to but not solved by #9628.

Expected behavior
When an object with value 0 (e.g. { name: 'test', value: 0}) is preselected 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 Mar 23, 2021
@yigitfindikli
Copy link
Member

Hi @Timmeeeey,

Thanks for your suggestion, unfortunately '??' is not compatible with IE 11.

@yigitfindikli yigitfindikli reopened this Mar 24, 2021
@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 24, 2021
@yigitfindikli yigitfindikli self-assigned this Mar 24, 2021
@yigitfindikli yigitfindikli added this to the 11.3.2 milestone Mar 24, 2021
yigitfindikli added a commit that referenced this issue Mar 24, 2021
@yigitfindikli yigitfindikli added LTS-FIXED-10.1.1 Fixed in PrimeNG LTS 10.1.1 LTS-FIXED-9.2.6 Fixed in PrimeNG LTS 9.2.6 and removed LTS-PORTABLE labels Apr 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTS-FIXED-9.2.6 Fixed in PrimeNG LTS 9.2.6 LTS-FIXED-10.1.1 Fixed in PrimeNG LTS 10.1.1 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