-
Notifications
You must be signed in to change notification settings - Fork 990
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
MultiSelect: not selecting correct value when "options" objects contain property "value" #3392
Comments
Fixed your sandbox you were setting default values incorrectly: https://codesandbox.io/s/mystifying-einstein-9bezvf?file=/src/App.tsx |
@melloware I appreciate you fixing my sandbox, apologies for that. This is still an issue however. Can we reopen it? |
@melloware should I not be using |
Fixed your sandbox again to use |
Thanks @melloware. Based on all the updates you've made in sandbox, it looks like the For example: This works
This will never work:
|
That will work just fine you just need to use 'optionValue="id"' to tell it to use the id field instead of default value field. |
@melloware I see, thanks! So it really boils down to the format of the |
I don't understand? Your use case makes no sense? Can you update your code sandbox to show what you are actually trying to do? You want the value to be instead of a single number and array of numbers? |
Here is my use case that works: https://codesandbox.io/s/friendly-bardeen-14m1u5?file=/src/App.tsx. Here is my use case that doesn't: https://codesandbox.io/s/hidden-field-p7ivin?file=/src/App.tsx. I think it is related to this line, where if the option has a Sorry for the confusion. |
Yes but in your example that doesn't work you are not using "optionValue="id" to tell it to use the Id value as your option? |
In the example that doesn't work https://codesandbox.io/s/hidden-field-p7ivin?file=/src/App.tsx, setting |
Ok let me take a look. I think I see what you are saying. |
@melloware just checking in, any updates? Should I submit a PR? |
Feel free. |
@melloware PR submitted |
@melloware @mertsincan any chance this can be added to the next release? |
I was waiting for PrimeTek to review before merging. |
Awesome, thanks! I wasn't sure what your process was, so just checking in. |
@mertsincan is there any particular reason why this is not being included in releases? I can't use this project without this change being released and may have to use a different library if this isn't going to be released soon. Thanks |
@erik-vanlankvelt sent you a note in your PR there is a merge conflict. |
@melloware I mucked up the git history so created a new PR for this that's clean. I'm sorry for the inconvenience. |
Thanks for the PR! Merged. |
Describe the Bug
I am not seeing selected "values" as checked in the dropdown. When checkboxes are checked, incorrect value is returned when "onChange" is invoked. "options" objects passed in contain a property/key named "value".
Reproducer
https://codesandbox.io/s/kind-bouman-2wobns?file=/src/App.tsx
PrimeReact version
8.5.0
React version
17.x
Language
React/TypeScript
Build / Runtime
Storybook
Browser(s)
Chrome
Steps to reproduce the behavior
Steps to reproduce correct behavior
const [value, setValue] = useState(defaultValueGood)
;const [value, setValue] = useState(defaultValueBad)
;const optionLabel = "name"
;const optionLabel = "label"
;options={optionsGood}
;options={optionsBad}
;The text was updated successfully, but these errors were encountered: