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: throws error when grouped item is selected #5445

Closed
matthew-dean opened this issue Mar 19, 2024 · 3 comments
Closed

Dropdown: throws error when grouped item is selected #5445

matthew-dean opened this issue Mar 19, 2024 · 3 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@matthew-dean
Copy link

matthew-dean commented Mar 19, 2024

Describe the bug

  1. Set up a grouped dropdown with a filter
  2. Set up an optiongroup and option template (I didn't want to do this, but grouping did not work without it)
  3. Select an item.
  4. PrimeVue Dropdown internals throw error on instance.label.length === 0 (instance's label prop is undefined)

Reproducer

https://stackblitz.com/edit/primevue-create-vue-typescript-issue-template-krpj4v?file=src%2FApp.vue

PrimeVue version

3.48.0 - 3.50.0

Vue version

3.x

Language

TypeScript

Build / Runtime

Vue CLI App

Browser(s)

No response

Steps to reproduce the behavior

See above

Expected behavior

Dropdown should not throw an internal error (ideally, even if a prop is missing? Which I can't tell if one is or not)

@matthew-dean matthew-dean added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Mar 19, 2024
@tugcekucukoglu tugcekucukoglu added this to the 3.51.0 milestone Apr 2, 2024
@tugcekucukoglu tugcekucukoglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Apr 2, 2024
@tugcekucukoglu tugcekucukoglu self-assigned this Apr 2, 2024
@matthew-dean
Copy link
Author

matthew-dean commented Apr 2, 2024

@tugcekucukoglu I see you fixed it, but can you tell me if there's anything else I could have done to avoid this issue to get it working in the short-term?

@matthew-dean
Copy link
Author

Okay, this has a target of 3.51.0. I just updated to 3.52.0. I can confirm that this no longer throws an error, but group selection still does not work. Selecting an item just shows the text "empty" in the selection box (wtf?).

@matthew-dean
Copy link
Author

matthew-dean commented Jun 4, 2024

I have tried a million ways to get Dropdowns to work when the values are objects. I've tried setting optionValue to be the id, and setting the v-model to the selectedId. I've verified that the id is being output by @update:modelValue. I've tried making sure that dataKey is explicitly set to the id. When the PrimeVue Dropdown is grouped, and the grouped items are objects, the internals just seem to break down entirely. There is no clear mechanism to map "which one is selected" to one of the sub-grouped items, and it always seems to display "empty". I can directly set a value, manually, from the update event, but the value doesn't seem to actually "select" one of the group children items, and always selects "empty".

Please add tests to Dropdown for when individual "values" of items are not strings. In the short term, can you please please tell me how this component is supposed to work with grouping and how to get it to work?

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