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 doesn't work as expected when working with Objects if the Object contains key named value #17469

Open
2 of 4 tasks
wildbsiu opened this issue Jan 22, 2025 · 0 comments
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@wildbsiu
Copy link

Describe the bug

Autocomplete doesn't behave as expected when working with objects and object has a key called value. When selecting an item from Autocomplete suggestion, expected selected item is supposed to be an object containing all the keys in the object. But selected item contains only value key.

However, if I simply rename value key to something else, say code, then behavior is as expected. Selected item in this contains all keys from the object.

Based on the example for Autocomplete when working with objects - https://primeng.org/autocomplete#objects, I have forked the StackBlitz example to showcase the issue at: https://stackblitz.com/edit/7pl9oavs-6kg2ha5d

Pull Request Link

No response

Reason for not contributing a PR

  • Lack of time
  • Unsure how to implement the fix/feature
  • Difficulty understanding the codebase
  • Other

Other Reason

No response

Reproducer

https://stackblitz.com/edit/7pl9oavs-6kg2ha5d

Environment

Windows 11

Angular version

19.0.1

PrimeNG version

v19

Node version

No response

Browser(s)

No response

Steps to reproduce the behavior

  1. Head to the StackBlitz example and run the same.
  2. Select any item from the autocomplete.
  3. Selected item json shows only the value key. e.g if you select United States, the selected item is shown as US instead of expected {name: 'United States', value: 'US'}
  4. Now, simply go the file countryservice.ts and rename key value to something else like code. Save and run.
  5. Selected item now shows full object.

Expected behavior

Selected item should contain all object keys

@wildbsiu wildbsiu added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jan 22, 2025
@wildbsiu wildbsiu changed the title Autocomplete doesn't work as expected when working with Objects if the Object contains key called value Autocomplete doesn't work as expected when working with Objects if the Object contains key named value Jan 22, 2025
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