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: default optionLabel and default optionValue are null (but doc say, default to label and value) #4174

Closed
deguich opened this issue Jul 20, 2023 · 8 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@deguich
Copy link

deguich commented Jul 20, 2023

Describe the bug

When using a simple dropdown with data like :

const data = [
  {label: "first", value: "firstval"},
  {label: "second", value: "secondval"}
];
const selectedData = ref();

This dropdown should show a list of labels, it shows the objects list :

<Dropdown
  v-model="selectedData"
  :options="data"
/>

Reproducer

https://codesandbox.io/p/sandbox/condescending-tu-n5pvck

PrimeVue version

3.30.2

Vue version

3.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

@deguich deguich added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jul 20, 2023
@mertsincan
Copy link
Member

Thanks a lot for the report! We'll check it.

@mertsincan mertsincan 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 Jul 20, 2023
@mertsincan mertsincan added this to the 3.30.3 milestone Jul 20, 2023
@deguich
Copy link
Author

deguich commented Jul 21, 2023

Hi, thanks.

But, I am wondering If the commit is the only one that fixes this bug, it may not be sufficient.

To be consistent with this part of documentation :

"Dropdown is used as a controlled component with v-model property along with an options collection. Label and value of an option are defined with the optionLabel and optionValue properties respectively. Default property name for the optionLabel is label and value for the optionValue. If optionValue is omitted and the object has no value property, the object itself becomes the value of an option. Note that, when options are simple primitive values such as a string array, no optionLabel and optionValue would be necessary."

optionLabel should have the following default value: 'label'
Similarly, optionValue should have the following default value: 'value'

Did I miss something?

Thx

@dkurucz
Copy link

dkurucz commented Aug 25, 2023

@deguich I am seeing the same thing, so I took a look at the source for dropdown and it appears things aren't working as documented... and it appears to be a pattern across lots of other selection-based controls. Working on a fix but it might be a bit.

@deguich
Copy link
Author

deguich commented Aug 28, 2023

Could you re-open this issue ?

@dkurucz
Copy link

dkurucz commented Aug 28, 2023

@deguich @mertsincan PR opened to fix this issue: #4340. Please review at earliest convenience. This is a blocker for my project and I will be referencing the fork until this is pulled in!

If I am missing anything such as a test scenario or documentation update, etc, please also let me know so I can address.

Thanks!

@tugcekucukoglu
Copy link
Member

Sorry for the confusion. Documentation will be fixed.

@deguich
Copy link
Author

deguich commented Sep 1, 2023

Hi,
I think the documentation is accurate and describes a functioning that should be correct.
Why don't fix the code ?

@mertsincan
Copy link
Member

Hi,
Please see; #4340 (comment)

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

4 participants