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

Dropdown: option is empty when it has group property and dropdown has [group]="false" #14304

Closed
tsinevik opened this issue Dec 8, 2023 · 2 comments · Fixed by #14382
Closed
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@tsinevik
Copy link
Contributor

tsinevik commented Dec 8, 2023

Describe the bug

I'm reopening the following issue #14276 because I think I didn't provide a clear explanation for my problem and the team member misunderstood me.

We're want to update from v16.6.0 to latest version of PrimeNG.

We have models in our app with a group property. Currently we using a lot of dropdowns that are using these models as options, some of these dropdowns using group property as a optionLabel or optionValue, BUT we don't use grouped options. After updating to latest version dropdowns render these options as empty:

image
image

It happens because internally PrimeNG decides which template to use based on existence of group property:

image

But I think not to break existing behavior this check should be handled the same way as in MultiSelect and Autocomplete components by checking multiple properties:

image image

As I see Dropdown component even has the same function implementation, it should be possible just to replace current check with this function call. For me it seems only logical that if @Input() group is set to false then it shouldn't choose group template at all.
And to rename all models and their usages or come up with some other solution just to return the previous behavior is far from ideal.

Environment

Any environment

Reproducer

https://stackblitz.com/edit/ee5k5j?file=src%2Fapp%2Fdemo%2Fdropdown-basic-demo.html,src%2Fapp%2Fdemo%2Fdropdown-basic-demo.ts

Angular version

17.0.0

PrimeNG version

17.0.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

18.18.0

Browser(s)

No response

Steps to reproduce the behavior

  1. Add a group property to any option.
  2. Add [group]="false" to Dropdown component.

The option is rendered empty even though we're not interested in grouped options.

https://stackblitz.com/edit/ee5k5j?file=src%2Fapp%2Fdemo%2Fdropdown-basic-demo.ts

And here's an example from v16.6.0
https://stackblitz.com/edit/dc7jhu?file=src%2Fapp%2Fdemo%2Fdropdown-basic-demo.ts,package.json

Expected behavior

The items should be rendered OR the docs should warn that group cannot be used as a property.

@tsinevik tsinevik added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Dec 8, 2023
@puschie286
Copy link

are there any workarounds beside renaming all properties with the name of 'group' ?

@tsinevik
Copy link
Contributor Author

tsinevik commented Jan 5, 2024

Hopefully the team will merge my PR at some point so we don't need to come up with some strange solutions 🙂

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

Successfully merging a pull request may close this issue.

2 participants