antoniandre / wave-ui

A UI framework for Vue.js 3 (and 2) with only the bright side. ☀️
https://antoniandre.github.io/wave-ui
MIT License
544 stars 39 forks source link

[w-checkbox] Fix checkbox custom value #128

Closed DerrikMilligan closed 10 months ago

DerrikMilligan commented 10 months ago

Currently we have the neat prop return-value on the w-checkbox but we don't actually use it to return values.

Here is a codepen of the issue. Note that the array only has true/false.

This still isn't perfect. With this setup we will get the correct value emitted but we can't actually just pass an array in the v-model like the Vue documentation shows. I'm guessing that's because there's some additional magic happening on an input with v-model.

One other option we could look at using is true-value and false-value that Vue supports on the input type checkbox by default. We may also need to hook into the input's actual v-model for these to work. We should be able to just pass along our modelValue for that. Wanted to see what you thought of this idea @antoniandre before I went for a larger set of changes.

antoniandre commented 10 months ago

Thanks for this PR @DerrikMilligan. Checking what you say and playing around in the codebase, I did the fix and added the return-values prop to w-checkboxes (all related commits referenced here). Released in version 3.7.0 Let me know if this is not completely addressing the original issue :)

DerrikMilligan commented 10 months ago

It would be nice if we also had this functionality on the w-checkbox itself. The w-checkboxes already works well using v-model on it with an array.

antoniandre commented 10 months ago

Hey @DerrikMilligan, this is indeed working with both w-checkbox and w-checkboxes now. Running your Codepen as is with the latest Wave UI will now return the return values

DerrikMilligan commented 10 months ago

Oh dang! I missed that you had two different commits! One for each! Thanks so much! You're awesome!

antoniandre commented 10 months ago

Yeah, I had a typo in my commit message referencing this PR. now corrected :p