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-list] Allow de-selecting items by updating the model value #123

Closed DerrikMilligan closed 11 months ago

DerrikMilligan commented 11 months ago

Currently on the w-list we have the method applySelectionOnItems which is called when the modelValue is changed from the watch method. Which can update the _selected property on the items to true but can not currently set it to false. This means that we can not modify the list of selected values to remove an item and have it de-select the value.

Here is a Codepen that demonstrates the issue. Note that when you click a button to select list item one we get the update, but when we remove the item we don't get the list updating correctly.

This pull request inverts the looping logic where it iterates over each listItems and checks to see if they exist in the array returned from checkSelection and updates the _selected value based upon whether it was found or not.

antoniandre commented 11 months ago

Thank you @DerrikMilligan! merged and released in 3.6.1