We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
getOption
value
Hi, thanks for your great package. When using an object as value, we can' t properly set the modelValue from the outside:
modelValue
multiselect/src/composables/useOptions.js
Lines 545 to 547 in f8af61b
Indeed, String(val) will be [Object object], as well as String(o), so the first object item in the list will be selected.
String(val)
[Object object]
String(o)
We could either use JSON.stringify instead of String, or let the user provide their own function.
JSON.stringify
What would you think?
I'd be glad to open a PR. Mathieu.
https://jsfiddle.net/jhrbdwk6/
The text was updated successfully, but these errors were encountered:
I've patched the package with yarn patch, and
yarn patch
- return eo.value[eo.value.map(o => String(o[valueProp.value])).indexOf(String(val))] + return eo.value[eo.value.map(o => JSON.stringify(o[valueProp.value])).indexOf(JSON.stringify(val))]
works pretty well.
(Btw I also wonder why you use an indexOf, instead of doing a standard find:
find
return eo.value.find(o => JSON.stringify(o[valueProp.value]) === JSON.stringify(val));
)
Sorry, something went wrong.
No branches or pull requests
Version
Description
Hi, thanks for your great package.
When using an object as value, we can' t properly set the
modelValue
from the outside:multiselect/src/composables/useOptions.js
Lines 545 to 547 in f8af61b
Indeed,
String(val)
will be[Object object]
, as well asString(o)
, so the first object item in the list will be selected.We could either use
JSON.stringify
instead of String, or let the user provide their own function.What would you think?
I'd be glad to open a PR.
Mathieu.
Demo
https://jsfiddle.net/jhrbdwk6/
The text was updated successfully, but these errors were encountered: